]> mj.ucw.cz Git - leo.git/blobdiff - leo.c
Labelling: Bugfixes in get_closure
[leo.git] / leo.c
diff --git a/leo.c b/leo.c
index 10092d657cfb6d4bbd95d943c589550897583113..003a2c55024af9b1787ca739283a19ad60c4fb49 100644 (file)
--- a/leo.c
+++ b/leo.c
@@ -17,8 +17,7 @@
 #include "css.h"
 #include "sym.h"
 #include "map.h"
-
-#undef ROTATE
+#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 +56,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--)
     {
@@ -115,78 +114,37 @@ static void draw_scale(struct svg *svg)
 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);
 
-  osm_init();
-  styles_init();
-
-  msg(L_INFO, "Parsing OSM");
-  osm_xml_parse(map_xml_input);
-  if (debug_dump_source)
-    {
-      puts("=== Source data ===");
-      osm_dump();
-    }
-  osm_make_multipolygons();
+  labeller_conf();
 
-  msg(L_INFO, "Projecting");
-  osm_project(map_projection);
-  if (debug_dump_after_proj)
-    {
-      puts("=== Map after projection ===");
-      osm_dump();
-    }
+  opt_parse(&options, argv+2);
+// TILL HERE
 
+  osm_init();
+  styles_init();
+  map_load_styles();
+  map_load_sources();
   map_set_scale();
-  if (debug_dump_after_scaling)
+
+  struct svg *svg = svg_open(map_svg_output);
+  if (!map_rotate)
     {
-      puts("=== Map after scaling ===");
-      osm_dump();
+      svg_set_attr_dimen(svg, "width", page_width);
+      svg_set_attr_dimen(svg, "height", page_height);
     }
-
-  struct css_sheet *ss = css_load(map_style_sheet);
-  if (debug_dump_css)
+  else
     {
-      puts("=== Stylesheet ===");
-      css_dump(ss);
+      svg_set_attr_dimen(svg, "width", page_height);
+      svg_set_attr_dimen(svg, "height", page_width);
     }
 
-  struct svg *svg = svg_open(map_svg_output);
-#ifndef ROTATE
-  svg_set_attr_dimen(svg, "width", page_width);
-  svg_set_attr_dimen(svg, "height", page_height);
-#else
-  svg_set_attr_dimen(svg, "width", page_height);
-  svg_set_attr_dimen(svg, "height", page_width);
-#endif
-
-  struct style_results r;
-  style_init(&r);
   sym_init();
+  labeller_init();
 
-  msg(L_INFO, "Applying stylesheet");
-  for (uns i = OSM_TYPE_NODE; i <= OSM_TYPE_MULTIPOLYGON; i++)
-    CLIST_FOR_EACH(struct osm_object *, o, osm_obj_list[i])
-      {
-       if (debug_dump_styling)
-         {
-           puts("===============================");
-           osm_obj_dump(o);
-         }
-       if (!map_object_visible_p(o))
-         {
-           if (debug_dump_styling)
-             printf("--> invisible\n");
-           continue;
-         }
-       style_begin(&r, o);
-       css_apply(ss, &r);
-       if (debug_dump_styling)
-         style_dump(&r);
-       sym_from_style(o, &r, svg);
-       style_end(&r);
-      }
+  map_apply_styles(svg);
 
   if (map_clip)
     {
@@ -206,17 +164,20 @@ int main(int argc UNUSED, char **argv)
 
       svg_push_element(svg, "g");
       svg_set_attr_format(svg, "clip-path", "url(#boundary)");
-#ifdef ROTATE
-      svg_set_attr_format(svg, "transform", "translate(%.6g,0) rotate(90)", page_height * svg->scale);
-#endif
+      if (map_rotate)
+       svg_set_attr_format(svg, "transform", "translate(%.6g,0) rotate(90)", page_height * svg->scale);
     }
 
   // FIXME: Replace by generic logo drawing facility
+#if 0
   struct svg_icon *logo = svg_icon_load(svg, "../logo/kocka-s-okrajem.svg");
+#endif
 
+  labeller_label();
   sym_draw_all(svg);
 
   // Draw logo
+#if 0
   double logo_width = 36.12;
   double logo_height = 36.12 / logo->width * logo->height;
   struct svg_icon_request sir = {
@@ -227,6 +188,7 @@ int main(int argc UNUSED, char **argv)
     .height = logo_height,
   };
   svg_icon_put(svg, &sir);
+#endif
 
   draw_scale(svg);