From: Karryanna Date: Tue, 12 May 2015 12:44:44 +0000 (+0200) Subject: Labelling: Individual is planned to map inside a function X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=aea2005031ba7d9516b085b6dca80753836be282;p=leo.git Labelling: Individual is planned to map inside a function --- diff --git a/labeller.c b/labeller.c index a0f3d57..91209d2 100644 --- a/labeller.c +++ b/labeller.c @@ -42,6 +42,7 @@ struct individual **population1; struct individual **population2; int dbg_segments = 0; +int dbg_plan = 0; int page_width_int; int page_height_int; @@ -101,6 +102,7 @@ void breed(void); void mutate(void); void elite(void); void rank_population(void); +void plan_individual(struct individual *individual); void make_bitmap(struct point_variant *v, struct symbol *sym); void make_bitmap_icon(struct point_variant *v, struct sym_icon *si); @@ -940,107 +942,103 @@ printf("(There are %d requests)\n", num_requests); printf("\nTotal penalty: %d\n", individual->penalty); } -void labeller_label(void) +void plan_individual(struct individual *individual) { - make_graph(); - label_graph(); -//dump_graph(); - bfs_wrapper(); -//dump_longlines(); - make_segments(); -dump_linelabel_requests(); - -printf("Having %u point requests, %u line requests and %u area requests\n", GARY_SIZE(requests_point), GARY_SIZE(requests_line), GARY_SIZE(requests_area)); - - GARY_INIT(population1, conf_pop_size); - GARY_INIT(population2, conf_pop_size); - make_population(); - - printf("Dealing with %d requests\n", num_requests); - -/* - while (! shall_terminate()) - { - iteration++; - - struct individual **swp = population1; - population1 = population2; - population2 = swp; - pop2_ind = 0; - } -*/ - - dump_individual(population1[0]); -//dump_bitmaps(population1[0]); - - for (uns i=0; iplacements); i++) + for (uns i=0; iplacements); i++) { -//printf("(%d) Coping with %d\n", i, population1[0]->placements[i].request->type); - struct symbol *s = NULL; z_index_t zindex = 0; - switch (population1[0]->placements[i].request->type) + switch (individual->placements[i].request->type) { case REQUEST_POINT: ; - struct request_point *rp = (struct request_point *) population1[0]->placements[i].request; + struct request_point *rp = (struct request_point *) individual->placements[i].request; s = rp->sym; zindex = rp->zindex; -// printf("%u\n", zindex); break; case REQUEST_SEGMENT: ; - struct request_segment *rs = (struct request_segment *) population1[0]->placements[i].request; + struct request_segment *rs = (struct request_segment *) individual->placements[i].request; s = rs->label; -// printf("Assigned label to s\n"); -// print_label(s); zindex = rs->zindex; -// printf("%u\n", zindex); break; case REQUEST_LINE: ; -// printf("*** Line detected ***\n"); break; case REQUEST_AREA: ; - struct request_area *ra = (struct request_area *) population1[0]->placements[i].request; + struct request_area *ra = (struct request_area *) individual->placements[i].request; s = ra->label; zindex = ra->zindex; -// printf("%u\n", zindex); break; default: -// printf("Testing request type (flushing final placements)\n"); - ASSERT(population1[0]->placements[i].request != REQUEST_INVALID); -// printf("Yep, in default, continuing\n"); + ASSERT(individual->placements[i].request != REQUEST_INVALID); continue; } -printf("Will plan symbol at [%.2f; %.2f] on %u\n", population1[0]->placements[i].x, population1[0]->placements[i].y, zindex); +if (dbg_plan) + printf("Will plan symbol at [%.2f; %.2f] on %u\n", individual->placements[i].x, individual->placements[i].y, zindex); if (s) switch (s->type) { case SYMBOLIZER_POINT: ; struct sym_point *sp = (struct sym_point *) s; - sp->x = population1[0]->placements[i].x; - sp->y = population1[0]->placements[i].y; + sp->x = individual->placements[i].x; + sp->y = individual->placements[i].y; sym_plan((struct symbol *) sp, zindex); break; case SYMBOLIZER_ICON: ; struct sym_icon *si = (struct sym_icon *) s; - si->sir.x = population1[0]->placements[i].x; - si->sir.y = population1[0]->placements[i].y; + si->sir.x = individual->placements[i].x; + si->sir.y = individual->placements[i].y; sym_plan((struct symbol *) si, zindex); break; case SYMBOLIZER_TEXT: ; struct sym_text *st = (struct sym_text *) s; - st->x = population1[0]->placements[i].x; - st->y = population1[0]->placements[i].y; + st->x = individual->placements[i].x; + st->y = individual->placements[i].y; st->next_duplicate = NULL; - printf("Planning text %s at [%.2f; %.2f] on %u\n", osm_val_decode(st->text), st->x, st->y, zindex); + if (dbg_plan) printf("Planning text %s at [%.2f; %.2f] on %u, with rotation %.2f\n", osm_val_decode(st->text), st->x, st->y, zindex, st->rotate); sym_plan((struct symbol *) st, zindex); break; default: -// printf("Testing symbolizer type\n"); ASSERT(s->type != SYMBOLIZER_INVALID); } } +} + +void labeller_label(void) +{ + make_graph(); + label_graph(); +//dump_graph(); + bfs_wrapper(); +//dump_longlines(); + make_segments(); +dump_linelabel_requests(); + +printf("Having %u point requests, %u line requests and %u area requests\n", GARY_SIZE(requests_point), GARY_SIZE(requests_line), GARY_SIZE(requests_area)); + + GARY_INIT(population1, conf_pop_size); + GARY_INIT(population2, conf_pop_size); + make_population(); + + printf("Dealing with %d requests\n", num_requests); + +/* + while (! shall_terminate()) + { + iteration++; + + struct individual **swp = population1; + population1 = population2; + population2 = swp; + pop2_ind = 0; + } +*/ + + dump_individual(population1[0]); +//dump_bitmaps(population1[0]); + + plan_individual(population1[0]); + labeller_cleanup(); return;