9 #include "lab-bitmaps.h"
10 #include "lab-utils.h"
11 #include "lab-evolution.h"
12 #include "lab-lines.h"
14 struct request_point *requests_point = NULL;
15 struct request_line *requests_line = NULL;
16 struct request_area *requests_area = NULL;
18 struct longline *longlines = NULL;
19 struct buffer_line *buffer_line = NULL;
20 struct buffer_linelabel *buffer_linelabel = NULL;
22 int dbg_segments = VERBOSITY_NONE;
23 int dbg_plan = VERBOSITY_NONE;
24 int dbg_requests = VERBOSITY_NONE;
25 int dbg_graph = VERBOSITY_NONE;
26 int dbg_bfs = VERBOSITY_NONE;
27 int dbg_map_parts = VERBOSITY_NONE;
28 int dbg_movement = VERBOSITY_NONE;
29 int dbg_init = VERBOSITY_NONE;
30 int dbg_overlaps = VERBOSITY_GENERAL;
31 int dbg_rank = VERBOSITY_NONE;
32 int dbg_evolution = VERBOSITY_POPULATION;
33 int dbg_mutation = VERBOSITY_NONE;
34 int dbg_breeding = VERBOSITY_NONE;
36 int page_width_int = 0;
37 int page_height_int = 0;
40 int num_placements = 0;
43 int conf_map_part_width = 5;
44 int conf_map_part_height = 5;
46 uns num_map_parts_row = 0;
47 uns num_map_parts_col = 0;
48 uns num_map_parts = 0;
50 static void labeller_add_linelabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
51 static void labeller_add_arealabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
53 static void compute_sizes(void);
55 static void compute_sizes(void)
57 page_width_int = floor(page_width);
58 page_height_int = floor(page_height);
60 num_map_parts_row = (page_width_int + conf_map_part_width) / conf_map_part_width;
61 num_map_parts_col = (page_height_int + conf_map_part_height) / conf_map_part_height;
62 num_map_parts = num_map_parts_row * num_map_parts_col;
66 void labeller_conf(void)
72 void labeller_init(void)
76 GARY_INIT(requests_point, 0);
77 GARY_INIT(requests_line, 0);
78 GARY_INIT(requests_area, 0);
79 GARY_INIT(buffer_line, 0);
80 GARY_INIT(buffer_linelabel, 0);
84 void labeller_add_point(struct symbol *sym, struct osm_object *object, z_index_t zindex)
86 DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Adding point\n");
87 if (object->type != OSM_TYPE_NODE)
89 printf("Warning: Point label requested on non-point object\n");
93 struct request_point *r = GARY_PUSH(requests_point);
95 r->request.type = REQUEST_POINT;
96 r->request.ind = num_requests++;
101 GARY_INIT(r->request.variants, 0);
103 struct variant *v = GARY_PUSH(r->request.variants);
105 struct osm_node *n = (struct osm_node *) object; // FIXME: Compiler warning
111 case SYMBOLIZER_ICON:
113 r->x = ((struct sym_icon *)sym)->sir.x;
114 r->y = ((struct sym_icon *)sym)->sir.y;
121 DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Inited point to [%.2f; %.2f] on %u\n", r->x, r->y, r->zindex);
124 void labeller_notify_line(struct symbol *sym, z_index_t zindex)
126 DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Adding line on %u\n", zindex);
127 struct buffer_line *b = GARY_PUSH(buffer_line);
128 b->line = (struct sym_line *) sym;
131 void labeller_add_label(struct symbol *sym, struct osm_object *o, z_index_t zindex)
136 if (osm_way_cyclic_p((struct osm_way *) o))
137 labeller_add_arealabel(sym, o, zindex);
139 labeller_add_linelabel(sym, o, zindex);
146 static void labeller_add_linelabel(struct symbol *sym, struct osm_object *o, z_index_t zindex)
148 if (o->type != OSM_TYPE_WAY)
150 printf("Linelabel request on object which is not way\n");
154 DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Labelling way %ju on %u\n", o->id, zindex);
155 struct buffer_linelabel *ll = GARY_PUSH(buffer_linelabel);
156 ll->way = (struct osm_way *) o;
161 static void labeller_add_arealabel(struct symbol *sym, struct osm_object *o, z_index_t zindex)
163 DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Adding area on %u\n", zindex);
164 struct request_area *r = GARY_PUSH(requests_area);
166 r->request.type = REQUEST_AREA;
167 r->request.ind = num_requests++;
169 r->o = (struct osm_multipolygon *) o;
173 osm_obj_center(o, &(r->cx), &(r->cy));
175 GARY_INIT(r->request.variants, 0);
176 struct variant *v = GARY_PUSH(r->request.variants);
180 void labeller_label(void)
188 void labeller_cleanup(void)
191 GARY_FREE(longlines);
193 GARY_FREE(requests_point);
194 GARY_FREE(requests_area);
196 for (uns i=0; i<GARY_SIZE(requests_line); i++)
198 for (uns j=0; j<GARY_SIZE(requests_line[i].sections); j++)
200 GARY_FREE(requests_line[i].sections[j].segments);
202 GARY_FREE(requests_line[i].sections);
204 GARY_FREE(requests_line);