2 * Hic Est Leo -- Main Program
4 * (c) 2014 Martin Mares <mj@ucw.cz>
22 uns debug_dump_source, debug_dump_after_proj, debug_dump_after_scaling;
23 uns debug_dump_multipolygons, debug_dump_css, debug_dump_styling, debug_dump_symbols;
25 static struct cf_section debug_cf = {
27 CF_UNS("DumpSource", &debug_dump_source),
28 CF_UNS("DumpAfterProj", &debug_dump_after_proj),
29 CF_UNS("DumpAfterScaling", &debug_dump_after_scaling),
30 CF_UNS("DumpMultipolygons", &debug_dump_multipolygons),
31 CF_UNS("DumpCSS", &debug_dump_css),
32 CF_UNS("DumpStyling", &debug_dump_styling),
33 CF_UNS("DumpSymbols", &debug_dump_symbols),
38 static const struct opt_section options = {
40 OPT_HELP("Hic Est Leo -- Experimental Map Renderer"),
49 // FIXME: Make generic
50 static void draw_scale(struct svg *svg)
53 double width = dist * map_scale;
54 double x = page_width - 10 - width;
57 svg_push_element(svg, "g");
58 svg_set_attr(svg, "id", "scale");
59 svg_set_attr_format(svg, "transform", "translate(%s,%s)", svg_format_dimen(svg, x), svg_format_dimen(svg, y));
61 for (int outline=1; outline>=0; outline--)
63 svg_push_element(svg, "g");
64 svg_set_attr(svg, "stroke-linecap", "square");
67 svg_set_attr_dimen(svg, "stroke-width", 1.5);
68 svg_set_attr_color(svg, "stroke", 0xffffff);
72 svg_set_attr_dimen(svg, "stroke-width", 0.5);
73 svg_set_attr_color(svg, "stroke", 0);
76 svg_push_element(svg, "line");
77 svg_set_attr_dimen(svg, "x1", 0);
78 svg_set_attr_dimen(svg, "y1", 0);
79 svg_set_attr_dimen(svg, "x2", width);
80 svg_set_attr_dimen(svg, "y2", 0);
83 for (int i=0; i<=10; i++)
98 svg_push_element(svg, "line");
99 svg_set_attr_dimen(svg, "x1", width * i/10);
100 svg_set_attr_dimen(svg, "y1", 0);
101 svg_set_attr_dimen(svg, "x2", width * i/10);
102 svg_set_attr_dimen(svg, "y1", -tick);
109 scale_text(svg, 0, 5, osm_val_encode("0"));
110 scale_text(svg, width, 5, osm_val_encode("1 km"));
114 int main(int argc UNUSED, char **argv)
116 cf_def_file = "map.cf";
118 cf_def_file = argv[1];
119 cf_declare_section("Debug", &debug_cf, 0);
120 opt_parse(&options, argv+2);
129 struct svg *svg = svg_open(map_svg_output);
132 svg_set_attr_dimen(svg, "width", page_width);
133 svg_set_attr_dimen(svg, "height", page_height);
137 svg_set_attr_dimen(svg, "width", page_height);
138 svg_set_attr_dimen(svg, "height", page_width);
144 map_apply_styles(svg);
148 svg_push_element(svg, "defs");
149 svg_push_element(svg, "clipPath");
150 svg_set_attr(svg, "id", "boundary");
152 svg_path_move_to(svg, page_offset_x, page_offset_y);
153 svg_path_line_to_rel(svg, page_map_width, 0);
154 svg_path_line_to_rel(svg, 0, page_map_height);
155 svg_path_line_to_rel(svg, -page_map_width, 0);
162 svg_push_element(svg, "g");
163 svg_set_attr_format(svg, "clip-path", "url(#boundary)");
165 svg_set_attr_format(svg, "transform", "translate(%.6g,0) rotate(90)", page_height * svg->scale);
168 // FIXME: Replace by generic logo drawing facility
170 struct svg_icon *logo = svg_icon_load(svg, "../logo/kocka-s-okrajem.svg");
178 double logo_width = 36.12;
179 double logo_height = 36.12 / logo->width * logo->height;
180 struct svg_icon_request sir = {
182 .x = page_width - 12 - logo_width / 2,
183 .y = 10 + logo_height / 2,
185 .height = logo_height,
187 svg_icon_put(svg, &sir);
197 svg_push_element(svg, "rect");
198 svg_set_attr_dimen(svg, "x", page_offset_x);
199 svg_set_attr_dimen(svg, "y", page_offset_y);
200 svg_set_attr_dimen(svg, "width", page_map_width);
201 svg_set_attr_dimen(svg, "height", page_map_height);
202 svg_set_attr(svg, "fill", "none");
203 svg_set_attr(svg, "stroke", "blue");
204 svg_set_attr_dimen(svg, "stroke-width", 0.2);
210 msg(L_INFO, "Finished");