X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=sym-text.c;h=8acfe4b0a1565683b658173c6a49da8b413c61ec;hb=refs%2Fheads%2Flabelling;hp=ffcfc421d78a516ddd446644ac0a86a312368d41;hpb=3d14be2fa32fe908dfef0f6ac3b76067c080a43a;p=leo.git diff --git a/sym-text.c b/sym-text.c index ffcfc42..8acfe4b 100644 --- a/sym-text.c +++ b/sym-text.c @@ -17,6 +17,7 @@ #include "osm.h" #include "sym.h" #include "map.h" +#include "labeller.h" /*** Fonts ***/ @@ -223,6 +224,23 @@ static void prepare_text_element(struct sym_text *t, struct svg *svg) svg_set_attr(svg, "font-style", osm_val_decode(font->style)); } +static struct symbol * sym_text_copy(struct symbol *sym) +{ + struct sym_text *t = (struct sym_text *) sym; + + struct sym_text *new = xmalloc(sizeof(struct sym_text)); + *new = *t; // FIXME: Is this OK? with respect to pointer fields... + + 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; @@ -446,8 +464,6 @@ static void sym_text_node(struct osm_object *o, struct style_info *si, osm_val_t msg(L_DEBUG, "Text <%s> dropped as duplicate", osm_val_decode(text)); return; } - - sym_plan(&st->s, sym_zindex(o, si, 5)); } static void sym_text_center(struct osm_object *o, struct style_info *si, osm_val_t text, double x, double y) @@ -462,7 +478,7 @@ static void sym_text_center(struct osm_object *o, struct style_info *si, osm_val st->x -= st->tw / 2; st->y += st->th - (st->th + st->td) / 2; text_fix_placement(st); - sym_plan(&st->s, sym_zindex(o, si, 4.9)); + labeller_add_label(&st->s, o, sym_zindex(o, si, 4.9)); } static void sym_text_way(struct osm_object *o, struct style_info *si, osm_val_t text) @@ -535,6 +551,8 @@ struct symbolizer symbolizer_text = { .draw = sym_text_draw, .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)