X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=sym-text.c;h=6622fd61fbd2b56b9c769b6be16484a7d2f10a07;hb=7982dd15d3d061b2abf80ccd98693003b965c5ab;hp=2666acd9f5d2e6f5984183750ad77b0a1ef2b7c8;hpb=44b0ec8816c3cf1a5858fec0c51e075cedefc3eb;p=leo.git diff --git a/sym-text.c b/sym-text.c index 2666acd..6622fd6 100644 --- a/sym-text.c +++ b/sym-text.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include FT_FREETYPE_H @@ -17,6 +18,8 @@ #include "sym.h" #include "map.h" +#include "labeller.h" + /*** Fonts ***/ struct text_font { @@ -225,6 +228,7 @@ static void prepare_text_element(struct sym_text *t, struct svg *svg) static void sym_text_draw(struct symbol *sym, struct svg *svg) { struct sym_text *t = (struct sym_text *) sym; +printf("Drawing %s at [%.2f; %.2f]\n", osm_val_decode(t->text), t->x, t->y); if (t->next_duplicate) { @@ -241,10 +245,16 @@ static void sym_text_draw(struct symbol *sym, struct svg *svg) t->y = sy / nn; } - if (t->opacity != 1) + bool use_group = 0; + bool want_rotate = (fabs(t->rotate) > 1e-5); + if (t->opacity != 1 || want_rotate) { + use_group = 1; svg_push_element(svg, "g"); - svg_set_attr_float(svg, "opacity", t->opacity); + if (t->opacity != 1) + svg_set_attr_float(svg, "opacity", t->opacity); + if (want_rotate) + svg_set_attr_format(svg, "transform", "rotate(%.2f %s %s)", -t->rotate, svg_format_dimen(svg, t->x), svg_format_dimen(svg, t->y)); } if (t->halo_radius) @@ -292,7 +302,7 @@ static void sym_text_draw(struct symbol *sym, struct svg *svg) svg_pop(svg); #endif - if (t->opacity != 1) + if (use_group) svg_pop(svg); } @@ -440,7 +450,7 @@ static void sym_text_node(struct osm_object *o, struct style_info *si, osm_val_t return; } - sym_plan(&st->s, sym_zindex(o, si, 5)); + //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) @@ -455,7 +465,18 @@ 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)); + if (o->type == OSM_TYPE_WAY && !osm_way_cyclic_p((struct osm_way *) o)) + { + //sym_plan(&st->s, sym_zindex(o, si, 4.9)); + printf("[Sym] Labelling way %ju with %s\n", o->id, osm_val_decode(st->text)); + labeller_add_linelabel(&st->s, o, sym_zindex(o, si, 4.9)); + } + else + { + //sym_plan(&st->s, sym_zindex(o, si, 4.9)); + printf("[Sym] Labelling area %ju with %s\n", o->id, osm_val_decode(st->text)); + labeller_add_arealabel(&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)