]> mj.ucw.cz Git - leo.git/blob - labeller.h
Labelling: Bugfixes in get_closure
[leo.git] / labeller.h
1 #ifndef _LEO_LABELLER_H
2 #define _LEO_LABELLER_H
3
4 #include "lab-utils.h"
5
6 /*
7 * Requests for point refer directly to point symbols that should be placed.
8 * Line and area requests are in fact requests for labels (either symbols or
9 * textual labels) of such objects.
10 * Area requests are taken quite as-is,
11 * line requests are broken into section and segment requests -- each line
12 * is broken into sections of maximal length and each section is made of segments
13 * which correspond to OSM ways.
14 * For each line, exactly one segment of each section is labelled in the output.
15 */
16
17 enum request_type
18 {
19   REQUEST_INVALID,
20   REQUEST_POINT,
21   REQUEST_AREA,
22   REQUEST_LINE,
23   REQUEST_SECTION,
24   REQUEST_SEGMENT,
25 };
26
27 struct variant
28 {
29   int width;
30   int height;
31   int offset_x;         // Desired offset of top-left corner with respect to
32   int offset_y;         // actual coordinates of corresponding object
33   bool *bitmap;         // Mask having 1s where the variant is not blank; used for overlap check
34 };
35
36 struct request
37 {
38   enum request_type type;
39   int ind;                      // Index used whenever request indexing is needed
40   struct variant *variants;     // Growing array of all variants usable for this request
41 };
42
43 struct request_point
44 {
45   struct request request;
46   struct symbol *sym;
47   z_index_t zindex;             // Needed when planning symbol
48   double x;
49   double y;
50 };
51
52 struct request_segment
53 {
54   struct request request;
55   struct symbol *label;
56   double x1;                    // Start and end of segment
57   double y1;
58   double x2;
59   double y2;
60   double slope;                 // Used to calculate label rotation
61   z_index_t zindex;             // Needed when planning symbol
62 };
63
64 struct request_section
65 {
66   struct request request;
67   struct request_segment *segments;     // Growing array
68 };
69
70 struct request_line
71 {
72   struct request request;
73   struct symbol *line;
74   struct request_section *sections;     // Growing array
75 };
76
77 struct request_area
78 {
79   struct request request;
80   struct osm_multipolygon *o;
81   struct symbol *label;
82   z_index_t zindex;
83   double cx, cy;                // Area center (coordinates average), used as reference coordinates
84 };
85
86 // Buffer for lines (osm_ways) added via labeller_notify_line,
87 // used to make graph and join lines which should be labelled as one object
88 struct buffer_line
89 {
90   struct sym_line *line;
91 };
92
93 // Buffer for line labes,
94 // used to label graph -- join logical lines with their labels
95 struct buffer_linelabel
96 {
97   struct osm_way *way;
98   struct symbol *label;
99   z_index_t zindex;
100 };
101
102 struct placement
103 {
104   struct request *request;
105   struct individual *individual;// FIXME: Is it needed?
106   double x;                     // Coordinates of variant top-left corner placement
107   double y;
108   int variant_used;             // Variant chosen for request in this placement
109   int ind;                      // Index used whenever placement indexing is needed
110   bool processed;               // FIXME: Is it needed?
111   // FIXME: Replace with clist?
112   struct map_placement *map_links;
113 };
114
115 struct map_placement
116 {
117   struct placement *placement;
118   struct map_part *part;
119   struct map_placement *next_in_map;
120   struct map_placement *prev_in_map;
121   struct map_placement *next_in_placement;
122   struct map_placement *prev_in_placement;
123 };
124
125 struct map_part
126 {
127   // FIXME: Replace with clist?
128   struct map_placement *placement;
129   int ind;
130 };
131
132 void labeller_conf(void);
133 void labeller_init(void);
134 void labeller_cleanup(void);
135
136 void labeller_label(void);
137
138 void labeller_add_point(struct symbol *sym, struct osm_object *object, z_index_t zindex);
139 void labeller_notify_line(struct symbol *sym, z_index_t zindex);
140 void labeller_add_label(struct symbol *sym, struct osm_object *o, z_index_t zindex);
141
142 extern struct request_point *requests_point;
143 extern struct request_line *requests_line;
144 extern struct request_area *requests_area;
145
146 extern struct longline *longlines;
147 extern struct buffer_line *buffer_line;
148 extern struct buffer_linelabel *buffer_linelabel;
149
150 extern int dbg_segments;
151 extern int dbg_plan;
152 extern int dbg_requests;
153 extern int dbg_graph;
154 extern int dbg_bfs;
155 extern int dbg_map_parts;
156 extern int dbg_movement;
157 extern int dbg_init;
158 extern int dbg_overlaps;
159 extern int dbg_rank;
160 extern int dbg_evolution;
161 extern int dbg_mutation;
162 extern int dbg_breeding;
163
164 extern int page_width_int;
165 extern int page_height_int;
166
167 extern int num_requests;
168 extern int num_placements;
169
170 extern int conf_map_part_width;
171 extern int conf_map_part_height;
172
173 extern uns num_map_parts_row;
174 extern uns num_map_parts_col;
175 extern uns num_map_parts;
176
177
178 #endif