/[zanavi_public1]/navit/navit/maptool/maptool.c
ZANavi

Contents of /navit/navit/maptool/maptool.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations) (download)
Sat Mar 8 17:10:49 2014 UTC (10 years, 1 month ago) by zoff99
File MIME type: text/plain
File size: 20298 byte(s)
new market version, lots of new features
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2011 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21 #define _FILE_OFFSET_BITS 64
22 #define _LARGEFILE_SOURCE
23 #define _LARGEFILE64_SOURCE
24 #include <stdlib.h>
25 #include <glib.h>
26 #include <assert.h>
27 #include <string.h>
28 #include <signal.h>
29 #include <stdio.h>
30 #include <math.h>
31 #include <getopt.h>
32 #include <unistd.h>
33 #include <fcntl.h>
34 #include <sys/stat.h>
35 #include <zlib.h>
36
37 #include "version_maptool.h"
38
39 #include "file.h"
40 #include "item.h"
41 #include "map.h"
42 #include "zipfile.h"
43 #include "main.h"
44 #include "config.h"
45 #include "linguistics.h"
46 #include "plugin.h"
47 #include "util.h"
48 #include "maptool.h"
49
50 long long slice_size=1024*1024*1024;
51 int attr_debug_level=1;
52 int ignore_unkown = 0;
53 int border_only_map = 0;
54 int coastline_only_map = 0;
55 GHashTable *dedupe_ways_hash;
56 int phase;
57 int slices;
58 int unknown_country;
59 int doway2poi=0;
60 char ch_suffix[] ="r"; /* Used to make compiler happy due to Bug 35903 in gcc */
61 int experimental=0;
62 int use_global_fixed_country_id=0;
63 int global_fixed_country_id=999;
64
65 struct buffer node_buffer = {
66 64*1024*1024,
67 };
68
69 int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles;
70
71 int overlap=1;
72
73 int bytes_read;
74
75
76
77 void
78 sig_alrm(int sig)
79 {
80 #ifndef _WIN32
81 signal(SIGALRM, sig_alrm);
82 alarm(120);
83 #endif
84 fprintf(stderr,"PROGRESS%d: Processed %d nodes (%d out) %d ways %d relations %d tiles\n", phase, processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles);
85 }
86
87 void
88 sig_alrm_end(void)
89 {
90 #ifndef _WIN32
91 alarm(0);
92 #endif
93 }
94
95 static struct plugins *plugins;
96
97 static void add_plugin(char *path)
98 {
99 struct attr **attrs;
100
101 if (! plugins)
102 plugins=plugins_new();
103 attrs=(struct attr*[]){&(struct attr){attr_path,{path}},NULL};
104 plugin_new(&(struct attr){attr_plugins,.u.plugins=plugins}, attrs);
105 }
106
107 static void
108 maptool_init(FILE* rule_file)
109 {
110 if (plugins)
111 plugins_init(plugins);
112 osm_init(rule_file);
113 }
114
115 static void
116 usage(FILE *f)
117 {
118 /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */
119 fprintf(f,"\n");
120 fprintf(f,"ZANavi maptool - parse osm textfile and convert to [Navit] binfile format\n");
121 fprintf(f,"version: "SVN_VERSION"\n\n");
122 fprintf(f,"Usage :\n");
123 fprintf(f,"bzcat planet.osm.bz2 | maptool mymap.bin\n");
124 fprintf(f,"Available switches:\n");
125 fprintf(f,"-h (--help) : this screen\n");
126 fprintf(f,"-5 (--md5) : set file where to write md5 sum\n");
127 fprintf(f,"-6 (--64bit) : set zip 64 bit compression\n");
128 fprintf(f,"-a (--attr-debug-level) : control which data is included in the debug attribute\n");
129 fprintf(f,"-c (--dump-coordinates) : dump coordinates after phase 1\n");
130 fprintf(f,"-X : generate country-border-ONLY map\n");
131 fprintf(f,"-Y : generate coastline-ONLY map\n");
132 #ifdef HAVE_POSTGRESQL
133 fprintf(f,"-d (--db) : get osm data out of a postgresql database with osm simple scheme and given connect string\n");
134 #endif
135 fprintf(f,"-e (--end) : end at specified phase\n");
136 fprintf(f,"-F : specify a fixed country id for this input file\n");
137 fprintf(f,"-i (--input-file) : specify the input file name (OSM), overrules default stdin\n");
138 fprintf(f,"-k (--keep-tmpfiles) : do not delete tmp files after processing. useful to reuse them\n\n");
139 fprintf(f,"-N (--nodes-only) : process only nodes\n");
140 fprintf(f,"-n : ignore unknown types\n");
141 fprintf(f,"-o (--coverage) : map every street to item coverage\n");
142 fprintf(f,"-P (--protobuf) : input file is protobuf\n");
143 fprintf(f,"-r (--rule-file) : read mapping rules from specified file\n");
144 fprintf(f,"-s (--start) : start at specified phase\n");
145 fprintf(f,"-S (--slice-size) : defines the amount of memory to use, in bytes. Default is 1GB\n");
146 fprintf(f,"-w (--dedupe-ways) : ensure no duplicate ways or nodes. useful when using several input files\n");
147 fprintf(f,"-W (--ways-only) : process only ways\n");
148 fprintf(f,"-z (--compression-level) : set the compression level\n");
149 fprintf(f,"-U (--unknown-country) : add objects with unknown country to index\n");
150
151 exit(1);
152 }
153
154 int main(int argc, char **argv)
155 {
156 FILE *ways=NULL,*ways_split=NULL,*ways_split_index=NULL,*towns=NULL,*nodes=NULL,*turn_restrictions=NULL,*graph=NULL,*coastline=NULL,*tilesdir,*coords,*relations=NULL,*boundaries=NULL;
157 FILE *files[10];
158 FILE *references[10];
159
160 #if 0
161 char *map=g_strdup(attrmap);
162 #endif
163 int zipnum,c,start=1,end=99,dump_coordinates=0;
164 int keep_tmpfiles=0;
165 int process_nodes=1, process_ways=1, process_relations=1;
166 #ifdef HAVE_ZLIB
167 int compression_level=9;
168 #else
169 int compression_level=0;
170 #endif
171 int zip64=0;
172 int output=0;
173 int input=0;
174 int protobuf=0;
175 int f,pos;
176 char *result,*optarg_cp,*attr_name,*attr_value;
177 char *protobufdb=NULL,*protobufdb_operation=NULL,*md5file=NULL;
178
179 use_global_fixed_country_id=0;
180
181 #ifdef HAVE_POSTGRESQL
182 char *dbstr=NULL;
183 #endif
184
185 FILE* input_file = stdin; // input data
186
187 FILE* rule_file = NULL; // external rule file
188
189 struct attr *attrs[10];
190 GList *map_handles=NULL;
191 struct map *handle;
192 struct maptool_osm osm;
193 #if 0
194 char *suffixes[]={"m0l0", "m0l1","m0l2","m0l3","m0l4","m0l5","m0l6"};
195 char *suffixes[]={"m","r"};
196 #else
197 char *suffixes[]={""};
198 #endif
199 char *suffix=suffixes[0];
200
201 int suffix_count=sizeof(suffixes)/sizeof(char *);
202 int i;
203 char r[] ="r"; /* Used to make compiler happy due to Bug 35903 in gcc */
204 main_init(argv[0]);
205 struct zip_info *zip_info=NULL;
206 int suffix_start=0;
207 char *timestamp=current_to_iso8601();
208 char *url=NULL;
209 #ifndef HAVE_GLIB
210 _g_slice_thread_init_nomessage();
211 #endif
212
213 osm.boundaries=NULL;
214 osm.turn_restrictions=NULL;
215 osm.nodes=NULL;
216 osm.ways=NULL;
217 osm.line2poi=NULL;
218 osm.poly2poi=NULL;
219 osm.towns=NULL;
220
221 // init the ling. hashes!!
222 linguistics_init();
223
224 while (1) {
225 #if 0
226 int this_option_optind = optind ? optind : 1;
227 #endif
228 int option_index = 0;
229 static struct option long_options[] = {
230 {"md5", 1, 0, '5'},
231 {"64bit", 0, 0, '6'},
232 {"attr-debug-level", 1, 0, 'a'},
233 {"binfile", 0, 0, 'b'},
234 {"compression-level", 1, 0, 'z'},
235 #ifdef HAVE_POSTGRESQL
236 {"db", 1, 0, 'd'},
237 #endif
238 {"dedupe-ways", 0, 0, 'w'},
239 {"dump", 0, 0, 'D'},
240 {"dump-coordinates", 0, 0, 'c'},
241 {"end", 1, 0, 'e'},
242 {"help", 0, 0, 'h'},
243 {"keep-tmpfiles", 0, 0, 'k'},
244 {"nodes-only", 0, 0, 'N'},
245 {"map", 1, 0, 'm'},
246 {"plugin", 1, 0, 'p'},
247 {"protobuf", 0, 0, 'P'},
248 {"start", 1, 0, 's'},
249 {"input-file", 1, 0, 'i'},
250 {"rule-file", 1, 0, 'r'},
251 {"ignore-unknown", 0, 0, 'n'},
252 {"url", 1, 0, 'u'},
253 {"ways-only", 0, 0, 'W'},
254 {"slice-size", 1, 0, 'S'},
255 {"unknown-country", 0, 0, 'U'},
256 {0, 0, 0, 0}
257 };
258 c = getopt_long (argc, argv, "5:6B:DF:NO:PWS:a:bc"
259 #ifdef HAVE_POSTGRESQL
260 "d:"
261 #endif
262 "e:hi:knm:p:r:s:wu:z:UXY", long_options, &option_index);
263 if (c == -1)
264 break;
265 switch (c) {
266 case '5':
267 md5file=optarg;
268 break;
269 case '6':
270 zip64=1;
271 break;
272 case 'B':
273 protobufdb=optarg;
274 break;
275 case 'D':
276 output=1;
277 break;
278 case 'N':
279 process_ways=0;
280 break;
281 case 'R':
282 process_relations=0;
283 break;
284 case 'O':
285 protobufdb_operation=optarg;
286 output=1;
287 break;
288 case 'P':
289 protobuf=1;
290 break;
291 case 'S':
292 slice_size=atoll(optarg);
293 break;
294 case 'W':
295 process_nodes=0;
296 break;
297 case 'U':
298 fprintf(stderr,"Towns in UNKNOWN Country will be added to index\n");
299 unknown_country=1;
300 break;
301 case 'X':
302 fprintf(stderr,"I will GENERATE a country-border-only map\n");
303 border_only_map=1;
304 break;
305 case 'Y':
306 fprintf(stderr,"I will GENERATE a coastline-only map\n");
307 coastline_only_map=1;
308 break;
309 case 'a':
310 attr_debug_level=atoi(optarg);
311 break;
312 case 'b':
313 input=1;
314 break;
315 case 'c':
316 dump_coordinates=1;
317 break;
318 #ifdef HAVE_POSTGRESQL
319 case 'd':
320 dbstr=optarg;
321 break;
322 #endif
323 case 'e':
324 end=atoi(optarg);
325 break;
326 case 'h':
327 usage(stdout);
328 break;
329 case 'm':
330 optarg_cp=g_strdup(optarg);
331 pos=0;
332 i=0;
333 attr_name=g_strdup(optarg);
334 attr_value=g_strdup(optarg);
335 while (i < 9 && attr_from_line(optarg_cp, NULL, &pos, attr_value, attr_name)) {
336 attrs[i]=attr_new_from_text(attr_name,attr_value);
337 if (attrs[i]) {
338 i++;
339 } else {
340 fprintf(stderr,"Failed to convert %s=%s to attribute\n",attr_name,attr_value);
341 }
342 attr_value=g_strdup(optarg);
343 }
344 attrs[i++]=NULL;
345 g_free(attr_value);
346 g_free(optarg_cp);
347 handle=map_new(NULL, attrs);
348 if (! handle) {
349 fprintf(stderr,"Failed to create map from attributes\n");
350 exit(1);
351 }
352 map_handles=g_list_append(map_handles,handle);
353 break;
354 case 'n':
355 fprintf(stderr,"I will IGNORE unknown types\n");
356 ignore_unkown=1;
357 break;
358 case 'k':
359 fprintf(stderr,"I will KEEP tmp files\n");
360 keep_tmpfiles=1;
361 break;
362 case 'p':
363 add_plugin(optarg);
364 break;
365 case 's':
366 start=atoi(optarg);
367 break;
368 case 'w':
369 dedupe_ways_hash=g_hash_table_new(NULL, NULL);
370 break;
371 case 'F':
372 use_global_fixed_country_id=1;
373 global_fixed_country_id=atoi(optarg);
374 fprintf(stderr,"ASSUME map is country id: %d\n",global_fixed_country_id);
375 break;
376 case 'i':
377 input_file = fopen( optarg, "r" );
378 if ( input_file == NULL )
379 {
380 fprintf( stderr, "\nInput file (%s) not found\n", optarg );
381 exit( -1 );
382 }
383 break;
384 case 'r':
385 rule_file = fopen( optarg, "r" );
386 if ( rule_file == NULL )
387 {
388 fprintf( stderr, "\nRule file (%s) not found\n", optarg );
389 exit( -1 );
390 }
391 break;
392 case 'u':
393 url=optarg;
394 break;
395 #ifdef HAVE_ZLIB
396 case 'z':
397 compression_level=atoi(optarg);
398 break;
399 #endif
400 case '?':
401 usage(stderr);
402 break;
403 default:
404 fprintf(stderr,"c=%d\n", c);
405 }
406
407 }
408 if (optind != argc-(output == 1 ? 0:1))
409 usage(stderr);
410 result=argv[optind];
411
412 // initialize plugins and OSM mappings
413 maptool_init(rule_file);
414 if (protobufdb_operation) {
415 osm_protobufdb_load(input_file, protobufdb);
416 return 0;
417 }
418
419 // input from an OSM file
420 if (input == 0) {
421 if (start == 1) {
422 unlink("coords.tmp");
423 if (process_ways)
424 ways=tempfile(suffix,"ways",1);
425 if (process_nodes)
426 {
427 nodes=tempfile(suffix,"nodes",1);
428 towns=tempfile(suffix,"towns",1);
429 }
430 if (process_ways && process_nodes)
431 turn_restrictions=tempfile(suffix,"turn_restrictions",1);
432 if (process_relations)
433 boundaries=tempfile(suffix,"boundaries",1);
434 phase=1;
435 fprintf(stderr,"PROGRESS: Phase 1: collecting data\n");
436 osm.ways=ways;
437 osm.nodes=nodes;
438 osm.towns=towns;
439 osm.turn_restrictions=turn_restrictions;
440 osm.boundaries=boundaries;
441 #ifdef HAVE_POSTGRESQL
442 if (dbstr)
443 map_collect_data_osm_db(dbstr,&osm);
444 else
445 #endif
446 if (map_handles)
447 {
448 GList *l;
449 phase1_map(map_handles,ways,nodes);
450 l=map_handles;
451 while (l) {
452 map_destroy(l->data);
453 l=g_list_next(l);
454 }
455 }
456 else if (protobuf)
457 {
458 map_collect_data_osm_protobuf(input_file,&osm);
459 }
460 else
461 {
462 map_collect_data_osm(input_file,&osm);
463 }
464 if (slices) {
465 fprintf(stderr,"%d slices\n",slices);
466 flush_nodes(1);
467 long long i_x_slice_size;
468 for (i = slices-2 ; i>=0 ; i--) {
469 fprintf(stderr, "slice %d of %d\n",slices-i-1,slices-1);
470 i_x_slice_size = i*slice_size;
471 //fprintf(stderr, "calling load_buffer 1 %d,"LONGLONG_FMT"\n",i,i_x_slice_size);
472 load_buffer("coords.tmp",&node_buffer, i_x_slice_size, slice_size);
473 // resolve_ways(ways, NULL);
474 ref_ways(ways); // *NEW*
475 save_buffer("coords.tmp",&node_buffer, i_x_slice_size);
476 }
477 } else
478 {
479 //fprintf(stderr, "calling save_buffer 2\n");
480 save_buffer("coords.tmp",&node_buffer, 0);
481 }
482 if (ways)
483 fclose(ways);
484 if (nodes)
485 fclose(nodes);
486 if (towns)
487 fclose(towns);
488 if (turn_restrictions)
489 fclose(turn_restrictions);
490 if (boundaries)
491 fclose(boundaries);
492 }
493 if (!slices) {
494 if (end == 1 || dump_coordinates)
495 flush_nodes(1);
496 else
497 slices++;
498 }
499 if (end == 1)
500 exit(0);
501 if (start == 2) {
502 load_buffer("coords.tmp",&node_buffer,0, slice_size);
503 }
504 if (start <= 2) {
505 if (process_ways) {
506 ways=tempfile(suffix,"ways",0);
507 phase=2;
508 fprintf(stderr,"PROGRESS: Phase 2: finding intersections\n");
509 for (i = 0 ; i < slices ; i++) {
510 int final=(i >= slices-1);
511 ways_split=tempfile(suffix,"ways_split",1);
512 ways_split_index=final ? tempfile(suffix,"ways_split_index",1) : NULL;
513 graph=tempfile(suffix,"graph",1);
514 coastline=tempfile(suffix,"coastline",1);
515 if (i)
516 load_buffer("coords.tmp",&node_buffer, i*slice_size, slice_size);
517 map_find_intersections(ways,ways_split,ways_split_index,graph,coastline,final);
518 fclose(ways_split);
519 if (ways_split_index)
520 fclose(ways_split_index);
521 fclose(ways);
522 fclose(graph);
523 fclose(coastline);
524 if (! final) {
525 tempfile_rename(suffix,"ways_split","ways_to_resolve");
526 ways=tempfile(suffix,"ways_to_resolve",0);
527 }
528 }
529 if(!keep_tmpfiles)
530 tempfile_unlink(suffix,"ways");
531 tempfile_unlink(suffix,"ways_to_resolve");
532 } else
533 fprintf(stderr,"PROGRESS: Skipping Phase 2\n");
534 }
535 free(node_buffer.base);
536 node_buffer.base=NULL;
537 node_buffer.malloced=0;
538 node_buffer.size=0;
539 if (end == 2)
540 exit(0);
541 } else {
542 ways_split=tempfile(suffix,"ways_split",0);
543 process_binfile(stdin, ways_split);
544 fclose(ways_split);
545 }
546
547 #if 1
548 FILE *coastline2=tempfile(suffix,"coastline",0);
549 if (coastline2) {
550 FILE *coastline_result=tempfile(suffix,"coastline_result",1);
551 process_coastlines(coastline2, coastline_result);
552 fclose(coastline_result);
553 fclose(coastline2);
554 }
555
556 //coastline=tempfile(suffix,"coastline",0);
557 //if (coastline) {
558 // ways_split=tempfile(suffix,"ways_split",2);
559 // fprintf(stderr,"coastline=%p\n",coastline);
560 // process_coastlines(coastline, ways_split);
561 // fclose(ways_split);
562 // fclose(coastline);
563 //}
564 #endif
565
566 FILE *towns2=tempfile(suffix,"towns",0);
567 FILE *boundaries2=NULL;
568 FILE *ways2=NULL;
569 if (towns2)
570 {
571 boundaries2=tempfile(suffix,"boundaries",0);
572 ways2=tempfile(suffix,"ways_split",0);
573 osm_process_towns(towns2,boundaries2,ways2);
574 fclose(ways2);
575 fclose(boundaries2);
576 fclose(towns2);
577 if(!keep_tmpfiles)
578 tempfile_unlink(suffix,"towns");
579 }
580
581 if (start <= 3) {
582 fprintf(stderr,"PROGRESS: Phase 3: sorting countries, generating turn restrictions\n");
583 sort_countries(keep_tmpfiles);
584 if (process_relations) {
585 #if 0
586 boundaries=tempfile(suffix,"boundaries",0);
587 ways_split=tempfile(suffix,"ways_split",0);
588 process_boundaries(boundaries, ways_split);
589 fclose(boundaries);
590 fclose(ways_split);
591 exit(0);
592 #endif
593 turn_restrictions=tempfile(suffix,"turn_restrictions",0);
594 if (turn_restrictions) {
595 relations=tempfile(suffix,"relations",1);
596 coords=fopen("coords.tmp","rb");
597 ways_split=tempfile(suffix,"ways_split",0);
598 ways_split_index=tempfile(suffix,"ways_split_index",0);
599 process_turn_restrictions(turn_restrictions,coords,ways_split,ways_split_index,relations);
600 fclose(ways_split_index);
601 fclose(ways_split);
602 fclose(coords);
603 fclose(relations);
604 fclose(turn_restrictions);
605 if(!keep_tmpfiles)
606 tempfile_unlink(suffix,"turn_restrictions");
607 }
608 }
609 if(!keep_tmpfiles)
610 tempfile_unlink(suffix,"ways_split_index");
611 }
612 if (end == 3)
613 exit(0);
614 if (output == 1) {
615 fprintf(stderr,"PROGRESS: Phase 4: dumping\n");
616 if (process_nodes) {
617 nodes=tempfile(suffix,"nodes",0);
618 if (nodes) {
619 dump(nodes);
620 fclose(nodes);
621 }
622 }
623 if (process_ways) {
624 ways_split=tempfile(suffix,"ways_split",0);
625 if (ways_split) {
626 dump(ways_split);
627 fclose(ways_split);
628 }
629 }
630 if (process_relations) {
631 relations=tempfile(suffix,"relations",0);
632 fprintf(stderr,"Relations=%p\n",relations);
633 if (relations) {
634 dump(relations);
635 fclose(relations);
636 }
637 }
638 exit(0);
639 }
640 for (i = suffix_start ; i < suffix_count ; i++) {
641 suffix=suffixes[i];
642 if (start <= 4) {
643 phase=3;
644 if (i == suffix_start) {
645 zip_info=zip_new();
646 zip_set_zip64(zip_info, zip64);
647 zip_set_timestamp(zip_info, timestamp);
648 }
649 zipnum=zip_get_zipnum(zip_info);
650 fprintf(stderr,"PROGRESS: Phase 4: generating tiles %s\n",suffix);
651 tilesdir=tempfile(suffix,"tilesdir",1);
652 if (!strcmp(suffix,r)) { /* Makes compiler happy due to bug 35903 in gcc */
653 ch_generate_tiles(suffixes[0],suffix,tilesdir,zip_info);
654 } else {
655 for (f = 0 ; f < 3 ; f++)
656 files[f]=NULL;
657 if (process_relations)
658 files[0]=tempfile(suffix,"relations",0);
659 if (process_ways)
660 files[1]=tempfile(suffix,"ways_split",0);
661 if (process_nodes)
662 files[2]=tempfile(suffix,"nodes",0);
663 phase4(files,3,0,suffix,tilesdir,zip_info);
664 for (f = 0 ; f < 3 ; f++) {
665 if (files[f])
666 fclose(files[f]);
667 }
668 }
669 fclose(tilesdir);
670 zip_set_zipnum(zip_info,zipnum);
671 }
672 if (end == 4)
673 exit(0);
674 if (zip_info) {
675 zip_destroy(zip_info);
676 zip_info=NULL;
677 }
678 if (start <= 5) {
679 phase=4;
680 fprintf(stderr,"PROGRESS: Phase 5: assembling map %s\n",suffix);
681 if (i == suffix_start) {
682 char *zipdir=tempfile_name("zipdir","");
683 char *zipindex=tempfile_name("index","");
684 zip_info=zip_new();
685 zip_set_zip64(zip_info, zip64);
686 zip_set_timestamp(zip_info, timestamp);
687 zip_set_maxnamelen(zip_info, 14+strlen(suffixes[0]));
688 zip_set_compression_level(zip_info, compression_level);
689 if (md5file)
690 zip_set_md5(zip_info, 1);
691 zip_open(zip_info, result, zipdir, zipindex);
692 if (url) {
693 map_information_attrs[1].type=attr_url;
694 map_information_attrs[1].u.str=url;
695 }
696 index_init(zip_info, 1);
697 }
698 if (!strcmp(suffix,r)) { /* Makes compiler happy due to bug 35903 in gcc */
699 ch_assemble_map(suffixes[0],suffix,zip_info);
700 } else {
701 for (f = 0 ; f < 3 ; f++) {
702 files[f]=NULL;
703 references[f]=NULL;
704 }
705 if (process_relations)
706 files[0]=tempfile(suffix,"relations",0);
707 if (process_ways) {
708 files[1]=tempfile(suffix,"ways_split",0);
709 references[1]=tempfile(suffix,"ways_split_ref",1);
710 }
711 if (process_nodes)
712 files[2]=tempfile(suffix,"nodes",0);
713 fprintf(stderr,"Slice %d\n",i);
714
715 phase5(files,references,3,0,suffix,zip_info);
716 for (f = 0 ; f < 3 ; f++) {
717 if (files[f])
718 fclose(files[f]);
719 if (references[f])
720 fclose(references[f]);
721 }
722 }
723 if(!keep_tmpfiles) {
724 tempfile_unlink(suffix,"relations");
725 tempfile_unlink(suffix,"nodes");
726 tempfile_unlink(suffix,"ways_split");
727 tempfile_unlink(suffix,"ways_split_ref");
728 tempfile_unlink(suffix,"coastline");
729 tempfile_unlink(suffix,"turn_restrictions");
730 tempfile_unlink(suffix,"graph");
731 tempfile_unlink(suffix,"tilesdir");
732 tempfile_unlink(suffix,"boundaries");
733 tempfile_unlink(suffix,"coastline_result");
734 unlink("coords.tmp");
735 }
736 if (i == suffix_count-1) {
737 unsigned char md5_data[16];
738 zipnum=zip_get_zipnum(zip_info);
739 add_aux_tiles("auxtiles.txt", zip_info);
740 write_countrydir(zip_info);
741 zip_set_zipnum(zip_info, zipnum);
742 write_aux_tiles(zip_info);
743 zip_write_index(zip_info);
744 zip_write_directory(zip_info);
745 zip_close(zip_info);
746 if (md5file && zip_get_md5(zip_info, md5_data)) {
747 FILE *md5=fopen(md5file,"w");
748 int i;
749 for (i = 0 ; i < 16 ; i++)
750 fprintf(md5,"%02x",md5_data[i]);
751 fprintf(md5,"\n");
752 fclose(md5);
753 }
754 if (!keep_tmpfiles) {
755 remove_countryfiles();
756 tempfile_unlink("index","");
757 tempfile_unlink("zipdir","");
758 }
759 }
760 }
761 }
762
763 fprintf(stderr,"PROGRESS: Phase 999: ### Map Ready ###\n");
764
765 return 0;
766 }

   
Visit the ZANavi Wiki