]> mj.ucw.cz Git - leo.git/blobdiff - leo.c
Simplify: Splitting of ways to non-branching segments
[leo.git] / leo.c
diff --git a/leo.c b/leo.c
index dea6cde89a684e6c87e83871add89e09ec6d261a..d7a39bd0f18aea3456ead193fad04b618dd93b6c 100644 (file)
--- a/leo.c
+++ b/leo.c
@@ -4,19 +4,21 @@
  *     (c) 2014 Martin Mares <mj@ucw.cz>
  */
 
-#include <ucw/lib.h>
+#include "leo.h"
+
 #include <ucw/conf.h>
 #include <ucw/opt.h>
 
 #include <stdio.h>
 
-#include "leo.h"
 #include "osm.h"
 #include "svg.h"
 #include "style.h"
 #include "css.h"
 #include "sym.h"
 #include "map.h"
+#include "graph.h"
+#include "simplify.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;
@@ -45,6 +47,7 @@ static const struct opt_section options = {
   }
 };
 
+#if 0
 // FIXME: Make generic
 static void draw_scale(struct svg *svg)
 {
@@ -55,7 +58,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--)
     {
@@ -109,6 +112,7 @@ static void draw_scale(struct svg *svg)
   scale_text(svg, width, 5, osm_val_encode("1 km"));
   svg_pop(svg);
 }
+#endif
 
 int main(int argc UNUSED, char **argv)
 {
@@ -118,37 +122,11 @@ int main(int argc UNUSED, char **argv)
 
   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();
-
-  msg(L_INFO, "Projecting");
-  osm_project(map_projection);
-  if (debug_dump_after_proj)
-    {
-      puts("=== Map after projection ===");
-      osm_dump();
-    }
-
+  map_load_styles();
+  map_load_sources();
+  graph_build();
   map_set_scale();
-  if (debug_dump_after_scaling)
-    {
-      puts("=== Map after scaling ===");
-      osm_dump();
-    }
-
-  struct css_sheet *ss = css_load(map_style_sheet);
-  if (debug_dump_css)
-    {
-      puts("=== Stylesheet ===");
-      css_dump(ss);
-    }
+  // map_generalize();
 
   struct svg *svg = svg_open(map_svg_output);
   if (!map_rotate)
@@ -162,32 +140,10 @@ int main(int argc UNUSED, char **argv)
       svg_set_attr_dimen(svg, "height", page_width);
     }
 
-  struct style_results r;
-  style_init(&r);
   sym_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);
+  simplify();
 
   if (map_clip)
     {
@@ -232,7 +188,9 @@ int main(int argc UNUSED, char **argv)
   svg_icon_put(svg, &sir);
 #endif
 
+#if 0
   draw_scale(svg);
+#endif
 
   if (map_clip)
     svg_pop(svg);