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

Diff of /navit/navit/maptool/osm_xml.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 56 Revision 57
130} 130}
131 131
132static int parse_way(char *p) 132static int parse_way(char *p)
133{ 133{
134 char id_buffer[BUFFER_SIZE]; 134 char id_buffer[BUFFER_SIZE];
135
135 if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE)) 136 if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
137 {
136 return 0; 138 return 0;
139 }
140
137 osm_add_way(atoll(id_buffer)); 141 osm_add_way(atoll(id_buffer));
138 return 1; 142 return 1;
139} 143}
140 144
141static int parse_relation(char *p) 145static int parse_relation(char *p)
203 int _e = 5000000; 207 int _e = 5000000;
204 int first_rel = 1; 208 int first_rel = 1;
205 int first_way = 1; 209 int first_way = 1;
206 int line_length = 0; 210 int line_length = 0;
207 211
212 int percent_int_1 = 0;
213 int percent_int_2 = 0;
214 int percent_int_3 = 0;
215 int phase = 0; // 0:nodes 1:ways 2:relations
216
208 buffer_ptr = malloc(size); 217 buffer_ptr = malloc(size);
209 218
210 //sig_alrm(0); 219 //sig_alrm(0);
211 220
212 // reset 221 // reset
263 else if (!strncmp(p, "<way ", 5)) 272 else if (!strncmp(p, "<way ", 5))
264 { 273 {
265 if (first_way == 1) 274 if (first_way == 1)
266 { 275 {
267 first_way = 0; 276 first_way = 0;
277
278 phase = 1;
268 279
269 flush_nodes(1, 0); // flush remaining nodes to "coords.tmp" from "osm_end_node" 280 flush_nodes(1, 0); // flush remaining nodes to "coords.tmp" from "osm_end_node"
270 free_buffer("dummy", &node_buffer[0]); // and free the memory 281 free_buffer("dummy", &node_buffer[0]); // and free the memory
271 282
272 sql_counter = 0; 283 sql_counter = 0;
325 { 336 {
326 if (first_rel == 1) 337 if (first_rel == 1)
327 { 338 {
328 first_rel = 0; 339 first_rel = 0;
329 340
341 phase = 2;
342
330 sql_counter = 0; 343 sql_counter = 0;
331 sql_counter2 = 0; 344 sql_counter2 = 0;
332 sql_counter3 = 0; 345 sql_counter3 = 0;
333 sql_counter4 = 0; 346 sql_counter4 = 0;
334 347
411 424
412 char outstring[200]; 425 char outstring[200];
413 char outstring2[200]; 426 char outstring2[200];
414 convert_to_human_time(diff2_tt, outstring); 427 convert_to_human_time(diff2_tt, outstring);
415 convert_to_human_bytes(pos_in, outstring2); 428 convert_to_human_bytes(pos_in, outstring2);
416 fprintf(stderr, "-RUNTIME-LOOP-COLLECT-DATA: %s elapsed (%s read)\n", outstring, outstring2); 429 fprintf_(stderr, "-RUNTIME-LOOP-COLLECT-DATA: %s elapsed (%s read)\n", outstring, outstring2);
417 convert_to_human_bytes((pos_in / diff2_tt), outstring2); 430 convert_to_human_bytes((pos_in / diff2_tt), outstring2);
418 fprintf(stderr, "-RUNTIME-LOOP-COLLECT-DATA: %s/s read\n", outstring2); 431 // fprintf_(stderr, "-RUNTIME-LOOP-COLLECT-DATA: %s/s read\n", outstring2);
419 432
420 convert_to_human_bytes((pos_in_local / diff_tt), outstring2); 433 convert_to_human_bytes((pos_in_local / diff_tt), outstring2);
421 fprintf(stderr, "-RUNTIME-LOOP-COLLECT-DATA (local loop): %s/s read\n", outstring2); 434 fprintf_(stderr, "-RUNTIME-LOOP-COLLECT-DATA (local loop): %s/s read\n", outstring2);
435
436 if (phase == 0)
437 {
438 if (processed_nodes_sum > 0)
439 {
440 percent_int_1 = (int)((processed_nodes * 100) / processed_nodes_sum);
441 }
442
443 // fprintf_(stderr, "sum=%d nodes=%d\n", (int)processed_nodes_sum, (int)processed_nodes);
444 }
445 else if (phase == 1)
446 {
447 percent_int_1 = 100;
448 if (processed_ways_sum > 0)
449 {
450 percent_int_2 = (int)((processed_ways * 100) / processed_ways_sum);
451 }
452 }
453 else if (phase == 2)
454 {
455 percent_int_2 = 100;
456 if (processed_relations_sum > 0)
457 {
458 percent_int_3 = (int)((processed_relations * 100) / processed_relations_sum);
459 }
460 }
461
462 fprintf_(stderr, "-RUNTIME-LOOP-COLLECT-DATA: [%d% | %d% | %d%] read\n", percent_int_1, percent_int_2, percent_int_3);
422 } 463 }
423 } 464 }
424 465
425 // just in case, commit all we got left over 466 // just in case, commit all we got left over
426 //if (sql_counter > 0) 467 //if (sql_counter > 0)
444 //} 485 //}
445 486
446 //sig_alrm(0); 487 //sig_alrm(0);
447 //sig_alrm_end(); 488 //sig_alrm_end();
448 489
490 processed_relations_sum = processed_relations;
491 processed_ways_sum = processed_ways;
492 processed_nodes_sum = processed_nodes;
493
494
449 free(buffer_ptr); 495 free(buffer_ptr);
450 496
451 return 1; 497 return 1;
452} 498}
453 499

Legend:
Removed from v.56  
changed lines
  Added in v.57

   
Visit the ZANavi Wiki