#include "sym.h"
#include "map.h"
+#include "labeller.h"
+
uns debug_dump_source, debug_dump_after_proj, debug_dump_after_scaling;
uns debug_dump_multipolygons, debug_dump_css, debug_dump_styling, debug_dump_symbols;
svg_push_element(svg, "g");
svg_set_attr(svg, "id", "scale");
- svg_set_attr_format(svg, "transform", "translate(%.6g,%.6g)", x * svg->scale, y * svg->scale);
+ svg_set_attr_format(svg, "transform", "translate(%s,%s)", svg_format_dimen(svg, x), svg_format_dimen(svg, y));
for (int outline=1; outline>=0; outline--)
{
int main(int argc UNUSED, char **argv)
{
cf_def_file = "map.cf";
+// HACKING
+ cf_def_file = argv[1];
cf_declare_section("Debug", &debug_cf, 0);
- opt_parse(&options, argv+1);
+ opt_parse(&options, argv+2);
+// TILL HERE
osm_init();
styles_init();
}
sym_init();
+ labeller_init();
map_apply_styles(svg);
struct svg_icon *logo = svg_icon_load(svg, "../logo/kocka-s-okrajem.svg");
#endif
+ labeller_label();
sym_draw_all(svg);
// Draw logo
#include <ucw/lib.h>
#include <ucw/stkstring.h>
+ #include <math.h>
#include <stdio.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include "sym.h"
#include "map.h"
+#include "labeller.h"
+
/*** Fonts ***/
struct text_font {
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)
{
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)
svg_pop(svg);
#endif
- if (t->opacity != 1)
+ if (use_group)
svg_pop(svg);
}
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)
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)