]> mj.ucw.cz Git - leo.git/blobdiff - lab-lines.c
Labelling: Bugfixes in get_closure
[leo.git] / lab-lines.c
index 35f9f457c53c3b9d7a9e53fe6a80ed20c0b23a2f..e33fd0a6891e1511a4d533f9c2c27ef421b6d2fe 100644 (file)
@@ -3,7 +3,6 @@
 #include <math.h>
 
 #include <ucw/lib.h>
-#include <ucw/conf.h>
 #include <ucw/gary.h>
 #include <ucw/mempool.h>
 
@@ -85,20 +84,7 @@ static int dbg_num_hits = 0;
 
 static struct graph_edge **bfs_queue;
 
-static double conf_max_section_length = 80, conf_max_section_overlay = 10;
-
-static struct cf_section lines_cf = {
-  CF_ITEMS {
-    CF_DOUBLE("MaxSectionLenght", &conf_max_section_length),
-    CF_DOUBLE("MaxSectionOverlay", &conf_max_section_overlay),
-    CF_END
-  }
-};
-
-void lines_conf(void)
-{
-  cf_declare_section("Labelling", &lines_cf, 0);
-}
+double conf_max_section_length = 80, conf_max_section_overlay = 10;
 
 static struct request_line *make_new_line(void)
 {
@@ -286,8 +272,7 @@ static void bfs_edge(struct graph_edge *e, struct graph_node *node, struct graph
 
     if (((other->n1->id == node->id) || (other->n2->id == node->id)) &&
         (e->label) && (other->label) &&
-        (e->label->type == SYMBOLIZER_TEXT) && (other->label->type == SYMBOLIZER_TEXT) &&
-        (((struct sym_text *) e->label)->text == ((struct sym_text *) other->label)->text))
+        (sym_look_same(e->label, other->label)))
     {
       if (! candidate || (other->length > candidate->length))
       candidate = other;
@@ -406,15 +391,7 @@ static void cut_edge(struct graph_edge *e, double dist)
   *new = *e;
   e->next = new;
 
-  switch (e->label->type)
-  {
-    case SYMBOLIZER_TEXT:
-      new->label = xmalloc(sizeof(struct sym_text));
-      *((struct sym_text *) new->label) = *((struct sym_text *) e->label);
-      break;
-    default:
-      ;
-  }
+  new->label = sym_copy(e->label);
 
   struct osm_node *n1 = e->n1->o;
   struct osm_node *n2 = e->n2->o;
@@ -505,8 +482,18 @@ static void make_segments(void)
       rs->x2 = e->n2->o->x;
       rs->y2 = e->n2->o->y;
 
-      rs->slope = (rs->y2 - rs->y1) / (rs->x2 - rs->x1);
-      ((struct sym_text *) rs->label)->rotate = convert_to_deg(atan(rs->slope));
+      if (fabs(rs->x2 - rs->x1) > 0.01)
+      {
+        rs->slope = (rs->y2 - rs->y1) / (rs->x2 - rs->x1);
+        // This works a little bit magically :)
+        // It's possible not to care about quadrants as it "just works" as expected
+        ((struct sym_text *) rs->label)->rotate = convert_to_deg(atan(rs->slope));
+      }
+      else
+      {
+        rs->slope = 142; // Magic!
+        ((struct sym_text *) rs->label)->rotate = 1;
+      }
       struct variant *v = GARY_PUSH(rs->request.variants);
       make_bitmap(v, rs->label);