]> mj.ucw.cz Git - leo.git/commitdiff
Merge branch 'master' into labelling
authorKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 12:29:25 +0000 (14:29 +0200)
committerKarryanna <karry@karryanna.cz>
Tue, 12 May 2015 12:29:25 +0000 (14:29 +0200)
1  2 
leo.c
sym-text.c
sym.h

diff --combined leo.c
index 75df2e7a4f3b85b4e24ee476da3f1116fd5c5ae1,b30996581f424d104a7775d91494fd0430810209..f22e5a50e2de10068658edcbae876840f70b6b30
--- 1/leo.c
--- 2/leo.c
+++ b/leo.c
@@@ -18,8 -18,6 +18,8 @@@
  #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;
  
@@@ -57,7 -55,7 +57,7 @@@ static void draw_scale(struct svg *svg
  
    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
diff --combined sym-text.c
index 3188938a38fd151c92998fce6005a493b3cb7904,ffcfc421d78a516ddd446644ac0a86a312368d41..6622fd61fbd2b56b9c769b6be16484a7d2f10a07
@@@ -7,6 -7,7 +7,7 @@@
  #include <ucw/lib.h>
  #include <ucw/stkstring.h>
  
+ #include <math.h>
  #include <stdio.h>
  #include <ft2build.h>
  #include FT_FREETYPE_H
@@@ -17,8 -18,6 +18,8 @@@
  #include "sym.h"
  #include "map.h"
  
 +#include "labeller.h"
 +
  /*** Fonts ***/
  
  struct text_font {
@@@ -227,7 -226,6 +228,7 @@@ static void prepare_text_element(struc
  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);
  }
  
@@@ -443,7 -447,7 +450,7 @@@ static void sym_text_node(struct osm_ob
        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)
diff --combined sym.h
index 6af4f2b163a9ad52c77ba981f918b27afc521e94,e53409e7b8d9ecc9a35874bfae3ff72bdad4d1fa..d2e294c893c7afc541c99984b19039da35075c84
--- 1/sym.h
--- 2/sym.h
+++ b/sym.h
@@@ -71,8 -71,6 +71,8 @@@ struct sym_point 
    double fill_opacity;
    bool do_stroke;
    bool do_fill;
 +  double x;
 +  double y;
  };
  
  // FIXME: Make sym_*_new() and symbolizer structs internal
@@@ -134,6 -132,7 +134,7 @@@ struct sym_text 
    color_t text_color;
    double x;
    double y;
+   double rotate;                      // Rotation in degrees CCW
    struct text_font *font;
    double opacity;
    color_t halo_color;