From: Karryanna Date: Wed, 1 Jul 2015 16:16:02 +0000 (+0200) Subject: Symbolizers may visually compare two symbols X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=597a0c524295c721a9f1a150463b1edfa228ca4a;p=leo.git Symbolizers may visually compare two symbols --- diff --git a/lab-lines.c b/lab-lines.c index a329973..1ec7a3f 100644 --- a/lab-lines.c +++ b/lab-lines.c @@ -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; diff --git a/sym-text.c b/sym-text.c index 9f61f7d..8acfe4b 100644 --- a/sym-text.c +++ b/sym-text.c @@ -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 752bea6..c978019 100644 --- 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 cb4ac12..53ba3fa 100644 --- 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 */