]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: Cleanup among debug prints
authorKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 19:03:46 +0000 (21:03 +0200)
committerKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 19:03:46 +0000 (21:03 +0200)
labeller.c

index 514819e26428aee065cdb6060af29a53e0ca3b88..fe062caec0fe029f7329a847d2f60500264b696a 100644 (file)
@@ -43,6 +43,11 @@ struct individual **population2;
 
 int dbg_segments = 0;
 int dbg_plan = 0;
+int dbg_requests = 0;
+int dbg_graph = 0;
+int dbg_bfs = 0;
+int dbg_map_parts = 0;
+int dbg_movement = 0;
 
 int page_width_int;
 int page_height_int;
@@ -324,7 +329,8 @@ printf("Adding point\n");
 
 void labeller_add_line(struct symbol *sym, z_index_t zindex)
 {
-printf("Adding line on %u\n", zindex);
+  if (dbg_requests)
+    printf("Adding line on %u\n", zindex);
   struct buffer_line *b = GARY_PUSH(buffer_line);
   b->line = (struct sym_line *) sym;
   b->zindex = zindex;
@@ -468,14 +474,17 @@ void dump_graph(void)
 
 void label_graph(void)
 {
-printf("There are %u line labels requested\n", GARY_SIZE(buffer_linelabel));
+  if (dbg_graph)
+    printf("There are %u line labels requested\n", GARY_SIZE(buffer_linelabel));
   for (uns i=0; i<GARY_SIZE(buffer_linelabel); i++)
   {
     if (buffer_linelabel[i].label->type == SYMBOLIZER_TEXT)
-    printf("Labelling nodes of way %s\n", osm_val_decode(((struct sym_text *) buffer_linelabel[i].label)->text));
+    if (dbg_graph)
+      printf("Labelling nodes of way %s\n", osm_val_decode(((struct sym_text *) buffer_linelabel[i].label)->text));
     CLIST_FOR_EACH(struct osm_ref *, ref, buffer_linelabel[i].way->nodes)
     {
-      printf("Looking for node %ju\n", ref->o->id);
+      if (dbg_graph)
+        printf("Looking for node %ju\n", ref->o->id);
       struct graph_node *n = hash_find(ref->o->id);
       if (n == NULL)
       {
@@ -483,12 +492,14 @@ printf("There are %u line labels requested\n", GARY_SIZE(buffer_linelabel));
       }
       else
       {
-        printf("Searching among %u edges\n", GARY_SIZE(n->edges));
+        if (dbg_graph)
+          printf("Searching among %u edges\n", GARY_SIZE(n->edges));
         for (uns j=0; j<GARY_SIZE(n->edges); j++)
         {
           if (n->edges[j]->id == buffer_linelabel[i].way->o.id)
           {
-            printf("Labelling node %ju\n", n->id);
+            if (dbg_graph)
+              printf("Labelling node %ju\n", n->id);
             n->edges[j]->label = buffer_linelabel[i].label;
             n->edges[j]->zindex = buffer_linelabel[i].zindex;
           }
@@ -500,19 +511,18 @@ printf("There are %u line labels requested\n", GARY_SIZE(buffer_linelabel));
 
 void bfs_edge(struct graph_edge *e, struct graph_node *node, struct graph_node *anode, enum edge_dir dir)
 {
-printf("BFS edge called for edge %d (going %d) in direction %d\n", e->num, e->dir, dir);
+  if (dbg_bfs)
+    printf("BFS edge called for edge %d (going %d) in direction %d\n", e->num, e->dir, dir);
   struct graph_edge *candidate = NULL;
 
   for (uns i=0; i<GARY_SIZE(node->edges); i++)
   {
     struct graph_edge *other = node->edges[i];
-if (e->num == 987) printf("Got label %d\n", e->num);
     if ((other->longline != (uns) -1) && (other->longline != e->longline)) continue;
-if (e->num == 987) printf("Continuing with edge %d\n", e->num);
 
-printf("Testing %d ?= %d\n", other->visited, e->longline);
     if ((uns) other->visited != e->longline) {
-    printf("Pushing new edge %d / %ju\n", other->num, other->id);
+    if (dbg_bfs)
+      printf("Pushing new edge %d / %ju\n", other->num, other->id);
     struct graph_edge **e_ptr = GARY_PUSH(bfs_queue);
     *e_ptr = other;
     other->visited = e->longline;
@@ -534,7 +544,8 @@ printf("Testing %d ?= %d\n", other->visited, e->longline);
 
   if (candidate)
   {
-printf("New line in longline %u\n", e->longline);
+    if (dbg_bfs)
+      printf("New line in longline %u\n", e->longline);
     struct graph_edge *other = candidate;
       other->longline = e->longline;
       other->dir = dir;
@@ -566,12 +577,15 @@ printf("New line in longline %u\n", e->longline);
 
 void bfs(uns longline)
 {
-printf("BFS called for longline %u\n", longline);
-printf("%d longlines are believed to exist, %d exist\n", num_longlines, GARY_SIZE(longlines));
+if (dbg_bfs)
+  printf("BFS called for longline %u\n", longline);
+if (dbg_bfs)
+  printf("%d longlines are believed to exist, %d exist\n", num_longlines, GARY_SIZE(longlines));
   for (uns i=0; i<GARY_SIZE(bfs_queue); i++)
   {
     struct graph_edge *cur = bfs_queue[i];
-    printf("Exploring new edge %d; %d remaining\n", cur->num, GARY_SIZE(bfs_queue));
+    if (dbg_bfs)
+      printf("Exploring new edge %d; %d remaining\n", cur->num, GARY_SIZE(bfs_queue));
     //ASSERT(! cur->visited);
 
     cur->visited = longline;
@@ -616,16 +630,20 @@ void bfs_wrapper(void)
       {
         GARY_PUSH(longlines);
         longlines[num_longlines].first = node->edges[i];
-        printf("Running new BFS\n");
-        printf("Creating longline %u\n", num_longlines);
+        if (dbg_bfs)
+          printf("Running new BFS\n");
+        if (dbg_bfs)
+          printf("Creating longline %u\n", num_longlines);
         GARY_RESIZE(bfs_queue, 0);
         struct graph_edge **e = GARY_PUSH(bfs_queue);
         *e = node->edges[i];
         node->edges[i]->longline = num_longlines;
         bfs(node->edges[i]->longline);
         //dump_longlines();
-        printf("Joined %d edges\n", dbg_num_hits); dbg_num_hits = 0;
-        printf("Planned %u edges\n", GARY_SIZE(bfs_queue));
+        if (dbg_bfs)
+          printf("Joined %d edges\n", dbg_num_hits); dbg_num_hits = 0;
+        if (dbg_bfs)
+          printf("Planned %u edges\n", GARY_SIZE(bfs_queue));
         num_longlines++;
       }
     }
@@ -748,12 +766,14 @@ void make_segments(void)
     }
     else
     {
-      printf("Warning: Skipping line\n");
+      if (dbg_segments)
+        printf("Warning: Skipping line\n");
       continue;
       // FIXME;
     }
 
-    printf("New longline\n");
+    if (dbg_segments)
+      printf("New longline\n");
     while (e)
     {
       if (e->visited < 0)
@@ -1012,11 +1032,8 @@ void labeller_label(void)
 {
   make_graph();
   label_graph();
-//dump_graph();
   bfs_wrapper();
-//dump_longlines();
   make_segments();
-dump_linelabel_requests();
 
 printf("Having %u point requests, %u line requests and %u area requests\n", GARY_SIZE(requests_point), GARY_SIZE(requests_line), GARY_SIZE(requests_area));
 
@@ -1038,9 +1055,6 @@ printf("Having %u point requests, %u line requests and %u area requests\n", GARY
   }
 */
 
-  dump_individual(population1[0]);
-//dump_bitmaps(population1[0]);
-
   plan_individual(population1[0]);
 
   labeller_cleanup();
@@ -1088,13 +1102,6 @@ void make_population(void)
 
     hide_segment_labels(individual);
 
-if (p != num_requests)
-{
-  printf("Say bye\n");
-  exit(42);
-}
-
-printf("Testing p\n");
     ASSERT(p == num_requests);
   }
 }
@@ -1348,10 +1355,12 @@ void gen_coords(struct placement *p)
       gen_coords_segment(p);
       break;
     case REQUEST_LINE:
-      printf("Not yet implemented\n");
+      if (dbg_movement)
+        printf("Not yet implemented\n");
       break;
     default:
-      printf("Testing request type\n");
+      if (dbg_movement)
+        printf("Testing request type\n");
       ASSERT(p->request->type != REQUEST_INVALID);
   }
 
@@ -1362,7 +1371,8 @@ double gen_movement(void)
 {
   double m = (random() % 1000000) / 10000;
   m = pow(m, 1.0/3) * flip(1, -1);
-  printf("Movement %.2f\n", m);
+  if (dbg_movement)
+    printf("Movement %.2f\n", m);
   return m;
 }
 
@@ -1466,7 +1476,8 @@ void move_symbol(struct placement *p)
     case REQUEST_LINE:
     case REQUEST_SEGMENT:
     case REQUEST_AREA:
-      printf("Not yet implemented\n");
+      if (dbg_movement)
+        printf("Not yet implemented\n");
     default:
       ASSERT(p->request->type != REQUEST_INVALID);
   }