]> mj.ucw.cz Git - leo.git/commitdiff
Symbolizers may visually compare two symbols
authorKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 16:16:02 +0000 (18:16 +0200)
committerKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 16:16:02 +0000 (18:16 +0200)
lab-lines.c
sym-text.c
sym.c
sym.h

index a32997317a57485c3d25e39a6fba45bb0bab3d31..1ec7a3fa3832cc110da82594d0899c01db0f18ed 100644 (file)
@@ -286,8 +286,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;
index 9f61f7d376443a1d0e3fee0f910e13f40520ca21..8acfe4b0a1565683b658173c6a49da8b413c61ec 100644 (file)
@@ -234,6 +234,13 @@ static struct symbol * sym_text_copy(struct symbol *sym)
   return (struct symbol *) new;
 }
 
+static bool sym_text_look_same(struct symbol *s1, struct symbol *s2)
+{
+  struct sym_text *st1 = (struct sym_text *) s1;
+  struct sym_text *st2 = (struct sym_text *) s2;
+  return (st1->text == st2->text && st1->text_color == st2->text_color);
+}
+
 static void sym_text_draw(struct symbol *sym, struct svg *svg)
 {
   struct sym_text *t = (struct sym_text *) sym;
@@ -545,6 +552,7 @@ struct symbolizer symbolizer_text = {
   .gen = sym_text_gen,
   .init = sym_text_init,
   .copy = sym_text_copy,
+  .look_same = sym_text_look_same,
 };
 
 struct sym_text *sym_text_new(struct osm_object *o)
diff --git a/sym.c b/sym.c
index 752bea609cf6bf2d128301a8616d033b2ebd3beb..c9780198d1e017fed75168292cd705c6e406d379 100644 (file)
--- a/sym.c
+++ b/sym.c
@@ -155,3 +155,15 @@ struct symbol * sym_copy(struct symbol *sym)
   else
     return NULL;
 }
+
+bool sym_look_same(struct symbol *s1, struct symbol *s2)
+{
+  if (s1->type != s2->type)
+    return false;
+
+  ASSERT(s1->type && s1->type < SYMBOLIZER_MAX);
+  if (symbolizers[s1->type]->look_same)
+    return symbolizers[s1->type]->look_same(s1, s2);
+  else
+    return false;
+}
diff --git a/sym.h b/sym.h
index cb4ac122713abf0c393d7c63bbcbcd4863f4ca5f..53ba3fa3b8fbc266b0f743cba664d8e04e086086 100644 (file)
--- a/sym.h
+++ b/sym.h
@@ -34,6 +34,7 @@ struct symbolizer {
   void (*gen)(struct osm_object *o, struct style_info *si, struct svg *svg);
   void (*init)(void);
   struct symbol* (*copy)(struct symbol *sym);
+  bool (*look_same)(struct symbol *s1, struct symbol *s2);
 };
 
 extern struct mempool *sym_mp;
@@ -60,6 +61,7 @@ void sym_from_style(struct osm_object *o, struct style_results *sr, struct svg *
 z_index_t sym_zindex(struct osm_object *o, struct style_info *si, double default_mzi);
 
 struct symbol * sym_copy(struct symbol *sym);
+bool sym_look_same(struct symbol *s1, struct symbol *s2);
 
 /* sym-point.c handles point symbols and icons */