]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: (Mostly) structs documentation and cleanup
authorKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 09:29:33 +0000 (11:29 +0200)
committerKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 09:29:33 +0000 (11:29 +0200)
lab-bitmaps.c
lab-evolution.c
lab-evolution.h
lab-lines.c
labeller.c
labeller.h

index 0769d34d54cce3745eb8e13dd27e0131c0d4f6f2..8845eac42ae0c4e80815df7a236b92ad826c7562 100644 (file)
@@ -11,6 +11,7 @@
 #include "labeller.h"
 #include "lab-bitmaps.h"
 #include "lab-utils.h"
+#include "lab-evolution.h"
 
 static void make_bitmap_icon(struct variant *v, struct sym_icon *si);
 static void make_bitmap_point(struct variant *v, struct sym_point *sp);
index 5b0bd71e45fa3e7cd93cf9b978c73280f36cf2e2..ccf7515f1d3148519d1c3d006594676e1106e47a 100644 (file)
@@ -744,7 +744,7 @@ static void init_placement(struct placement *p, struct individual *individual, s
       break;
     case REQUEST_SECTION: ;
       struct request_section *rls = (struct request_section *) r;
-      p->variant_used = randint(0, rls->num_segments);
+      p->variant_used = randint(0, GARY_SIZE(rls->segments));
       break;
     case REQUEST_SEGMENT: ;
       struct request_segment *rs = (struct request_segment *) r;
index cdd8af2acce88a6f34463881a98646dba88f7aba..f2aff81c038b2bebbd5e66461a0aa786a1ebbe58 100644 (file)
@@ -1,6 +1,13 @@
 #ifndef _LEO_LABELLER_EVOLUTION_H
 #define _LEO_LABELLER_EVOLUTION_H
 
+struct individual
+{
+  struct placement *placements;
+  struct map_part **map;
+  int penalty;
+};
+
 void evolution_conf(void);
 void evolution_init(void);
 
index 4436e4dff19525dd1bdf451044fa61b482c6b45a..e3c3005df336cf6503c73a0786293c91cd1efc45 100644 (file)
@@ -25,6 +25,7 @@ enum edge_dir
   DIR_BWD,
 };
 
+// List of lines (osm_ways) making up a logical line
 struct longline
 {
   uns id;
@@ -36,27 +37,25 @@ struct graph_node
   osm_id_t id;
   struct osm_node *o;
   struct graph_edge **edges;
-  int num;
+  int num;     // Used for debug, mostly debug prints
 };
 
 struct graph_edge
 {
-  osm_id_t id;
-  double length;
+  osm_id_t id;                 // Actual line (osm_way) ID
+  struct sym_line *line;
   color_t color;
-  int visited;
-  struct graph_edge *prev;
-  struct graph_edge *next;
-  struct graph_node *n1;
-  struct graph_node *n2;
-  uns longline;
   struct symbol *label;
-  struct sym_line *line;
-  z_index_t zindex;
-  enum edge_dir dir;
-  struct graph_node *anode;
-  struct graph_node *bnode; // DEBUG PRINT
-  int num; // DEBUG
+  z_index_t zindex;            // z-index of label
+  double length;
+  int visited;                 // Iteration when line was last visited with BFS
+  uns longline;                        // Logical line this line was made part of
+  enum edge_dir dir;           // Direction with respect to logical line, used by BFS
+  struct graph_node *n1;       // Actual line endpoints
+  struct graph_node *n2;
+  struct graph_edge *prev;     // Neighbouring lines in logical line
+  struct graph_edge *next;
+  int num;                     // Used for debug
 };
 
 #define HASH_NODE struct graph_node
@@ -117,7 +116,6 @@ static struct request_section *make_new_section(struct request_line *rl)
   struct request_section *rls = GARY_PUSH(rl->sections);
   rls->request.ind = num_requests++;
   rls->request.type = REQUEST_SECTION;
-  rls->num_segments = 0;
   GARY_INIT(rls->segments, 0);
   GARY_INIT(rls->request.variants, 0);
 
@@ -127,7 +125,6 @@ static struct request_section *make_new_section(struct request_line *rl)
 static struct request_segment *make_new_segment(struct request_section *rls, struct symbol *sym)
 {
   struct request_segment *rs = GARY_PUSH(rls->segments);
-  rls->num_segments++;
 
   rs->request.ind = num_requests++;
   rs->request.type = REQUEST_SEGMENT;
@@ -525,7 +522,7 @@ static void make_segments(void)
       e = e->next;
     }
 
-    if (request->sections[0].num_segments == 0)
+    if (GARY_SIZE(request->sections[0].segments) == 0)
     {
       DEBUG(dbg_segments, VERBOSITY_INDIVIDUAL, "WARNING: Longline without any segment, skipped\n");
 
index 6185108a46dc6e3cbb9a14bbf70d5fb33a56c492..71c0f5538c56b73499192d40d7967b7e3b89b118 100644 (file)
@@ -98,10 +98,6 @@ void labeller_add_point(struct symbol *sym, struct osm_object *object, z_index_t
   r->sym = sym;
   r->zindex = zindex;
 
-  r->offset_x = 0;
-  r->offset_y = 0;
-
-  r->num_variants = 1;
   GARY_INIT(r->request.variants, 0);
 
   struct variant *v = GARY_PUSH(r->request.variants);
@@ -130,7 +126,6 @@ void labeller_notify_line(struct symbol *sym, z_index_t zindex)
   DEBUG(dbg_requests, VERBOSITY_PLACEMENT, "Adding line on %u\n", zindex);
   struct buffer_line *b = GARY_PUSH(buffer_line);
   b->line = (struct sym_line *) sym;
-  b->zindex = zindex;
 }
 
 void labeller_add_label(struct symbol *sym, struct osm_object *o, z_index_t zindex)
index 4c0aacc4722a3cd48ed17f0d3ad236cb4f3f638d..3bd13e5f1e7204e2ac52fd9932d6a3b0d887c6b2 100644 (file)
@@ -3,6 +3,17 @@
 
 #include "lab-utils.h"
 
+/*
+* Requests for point refer directly to point symbols that should be placed.
+* Line and area requests are in fact requests for labels (either symbols or
+* textual labels) of such objects.
+* Area requests are taken quite as-is,
+* line requests are broken into section and segment requests -- each line
+* is broken into sections of maximal length and each section is made of segments
+* which correspond to OSM ways.
+* For each line, exactly one segment of each section is labelled in the output.
+*/
+
 enum request_type
 {
   REQUEST_INVALID,
@@ -17,56 +28,50 @@ struct variant
 {
   int width;
   int height;
-  int offset_x;
-  int offset_y;
-  bool *bitmap;
+  int offset_x;                // Desired offset of top-left corner with respect to
+  int offset_y;                // actual coordinates of corresponding object
+  bool *bitmap;                // Mask having 1s where the variant is not blank; used for overlap check
 };
 
 struct request
 {
   enum request_type type;
-  int ind;
-  struct variant *variants;
+  int ind;                     // Index used whenever request indexing is needed
+  struct variant *variants;    // Growing array of all variants usable for this request
 };
 
 struct request_point
 {
   struct request request;
   struct symbol *sym;
-  z_index_t zindex;
+  z_index_t zindex;            // Needed when planning symbol
   double x;
   double y;
-  double offset_x;
-  double offset_y;
-  int num_variants;
 };
 
 struct request_segment
 {
   struct request request;
-  struct request_line *rl;
-  double x1;
+  struct symbol *label;
+  double x1;                   // Start and end of segment
   double y1;
   double x2;
   double y2;
-  double slope;
-  struct symbol *label;
-  z_index_t zindex;
+  double slope;                        // Used to calculate label rotation
+  z_index_t zindex;            // Needed when planning symbol
 };
 
 struct request_section
 {
   struct request request;
-  int num_segments;
-  struct request_segment *segments;
+  struct request_segment *segments;    // Growing array
 };
 
 struct request_line
 {
   struct request request;
   struct symbol *line;
-  int num_variants;
-  struct request_section *sections;
+  struct request_section *sections;    // Growing array
 };
 
 struct request_area
@@ -75,15 +80,18 @@ struct request_area
   struct osm_multipolygon *o;
   struct symbol *label;
   z_index_t zindex;
-  double cx, cy;
+  double cx, cy;               // Area center (coordinates average), used as reference coordinates
 };
 
+// Buffer for lines (osm_ways) added via labeller_notify_line,
+// used to make graph and join lines which should be labelled as one object
 struct buffer_line
 {
   struct sym_line *line;
-  z_index_t zindex;
 };
 
+// Buffer for line labes,
+// used to label graph -- join logical lines with their labels
 struct buffer_linelabel
 {
   struct osm_way *way;
@@ -94,14 +102,14 @@ struct buffer_linelabel
 struct placement
 {
   struct request *request;
-  double x;
+  struct individual *individual;// FIXME: Is it needed?
+  double x;                    // Coordinates of variant top-left corner placement
   double y;
-  int variant_used;
-  int ind;
-  bool processed;
+  int variant_used;            // Variant chosen for request in this placement
+  int ind;                     // Index used whenever placement indexing is needed
+  bool processed;              // FIXME: Is it needed?
   // FIXME: Replace with clist?
   struct map_placement *map_links;
-  struct individual *individual;
 };
 
 struct map_placement
@@ -121,13 +129,6 @@ struct map_part
   int ind;
 };
 
-struct individual
-{
-  struct placement *placements;
-  struct map_part **map;
-  int penalty;
-};
-
 void labeller_conf(void);
 void labeller_init(void);
 void labeller_cleanup(void);