From 48a81d7683069fc5d80937ca361359ed6001e58d Mon Sep 17 00:00:00 2001 From: steffen Date: Sun, 5 May 2013 20:05:36 +0000 Subject: [PATCH] adding max subid to areas.. --- draw/draw.c | 14 +++++++------- mapsys/map_osmload.c | 25 +++++++++++++++---------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/draw/draw.c b/draw/draw.c index 1d479fc..020278a 100644 --- a/draw/draw.c +++ b/draw/draw.c @@ -485,13 +485,13 @@ void draw_map () { || ((view_scale < 0.1 && (n % 2) == 0) || carea->p_cnt < 5) || ((view_scale < 0.1 && (n % 4) == 0) || carea->p_cnt < 10)) { p1 = draw_geo2screen (view_lon, view_lat, carea->p[n].lon, carea->p[n].lat); - // if (n == 0) { - // draw_line (img_map, p1.x + center.x - 5, p1.y + center.y - 5, p1.x + center.x + 5, p1.y + center.y + 5, tmplinestyle); - // draw_line (img_map, p1.x + center.x + 5, p1.y + center.y - 5, p1.x + center.x - 5, p1.y + center.y + 5, tmplinestyle); - // } - // if (n == 0) sprintf (text, "%d:%d", n, carea->subid); - // else sprintf (text, "%d", n); - // gfx_draw_text (img_map, p1.x + center.x - 20, p1.y + center.y - 10, text, &color[COLOR_white][3]); +// if (n == 0) { +// draw_line (img_map, p1.x + center.x - 5, p1.y + center.y - 5, p1.x + center.x + 5, p1.y + center.y + 5, tmplinestyle); +// draw_line (img_map, p1.x + center.x + 5, p1.y + center.y - 5, p1.x + center.x - 5, p1.y + center.y + 5, tmplinestyle); +// } +// if (n == 0) sprintf (text, "%d:%d", n, carea->subid); +// else sprintf (text, "%d", n); +// gfx_draw_text (img_map, p1.x + center.x - 20, p1.y + center.y - 10, text, &color[COLOR_white][3]); draw_polygonadd (p1.x + center.x, p1.y + center.y); } draw_polygonfinish (img_map, tmplinestyle, &color_polygon[carea->type], 0); diff --git a/mapsys/map_osmload.c b/mapsys/map_osmload.c index 7c1f97c..4e6f7c2 100644 --- a/mapsys/map_osmload.c +++ b/mapsys/map_osmload.c @@ -1179,15 +1179,16 @@ struct s_osmareapnt { }; +#define MAX_SUBID 100 int osm_area_split_add (struct s_osmmarea *marea) { /* allocate enought memory */ struct map_area *a = NULL; struct s_osmareapnt *pall = ml_malloc (sizeof (struct s_osmareapnt) * marea->marea->p_cnt); int pall_cnt = marea->marea->p_cnt; int i, j, c, k, smaller; - int _debug = 0; +// int _debug = 0; -// if (marea->marea->id == 29225778) _debug = 1; +// if (marea->marea->id == 4470478) _debug = 1; // else return 1; // d_printf ("marea: %lld cnt:%d", marea->marea->id, marea->marea->p_cnt); // map_area_add (marea->marea, MHLOAD_RELOAD); @@ -1213,7 +1214,7 @@ int osm_area_split_add (struct s_osmmarea *marea) { } pall_cnt = c; - while (pall[0].pnr >= 0 && pall_cnt > 2) { + while (pall[0].pnr >= 0 && pall_cnt > 2 && a->subid < MAX_SUBID) { /* j - will keep first ptr to start checking polygon * c - counter how many angles > 180° */ // d_printf ("**************** subid:%d pallcnt:%d", a->subid, pall_cnt); @@ -1286,7 +1287,7 @@ int osm_area_split_add (struct s_osmmarea *marea) { i_old = s = i; angle_old = angle = 0.0; - if (_debug) d_printf ("pall_cnt:%d c:%d s:%d j:%d", pall_cnt, c, s, j); +// if (_debug) d_printf ("pall_cnt:%d c:%d s:%d j:%d", pall_cnt, c, s, j); /* loop as long as angle is increasing and below 180° */ for (; i != j && angle_old <= angle && angle <= M_PI;) { @@ -1306,12 +1307,12 @@ int osm_area_split_add (struct s_osmmarea *marea) { // if (_debug) d_printf ("j:%d i:%d s:%d k:%d angle:%f angle_old:%f pall[i].angle:%f", // j, i, s, k, angle, angle_old, pall[i].angle); -// /* last visible point */ -// if (pall[i].angle > M_PI) { + /* last visible point */ + if (pall[i].angle > M_PI) { // if (_debug) d_printf ("added %d pnr:%d", k, pall[i].pnr); -// a->p[k++] = marea->marea->p[pall[i].pnr]; /* copy point */ -// } -// else + a->p[k++] = marea->marea->p[pall[i].pnr]; /* copy point */ + } + else if (angle_old > angle) { pall[i_old].pnr = pnr_old; } @@ -1340,10 +1341,14 @@ int osm_area_split_add (struct s_osmmarea *marea) { pall_cnt = k; } + if (a->subid >= MAX_SUBID) { + d_printf ("%s:%d max subid reached. area id:%lld", __FILE__, __LINE__, a->id); + } + // if (_debug) d_printf ("j:%d c:%d", j, c); if (pall[0].pnr >= 0 && pall_cnt > 0) { d_printf ("%s:%d osm_area_split_add: something went very wrong", __FILE__, __LINE__); - d_printf (" marea->id: %lld:%d", marea->marea->id, marea->marea->subid); + d_printf (" marea->id: %lld:%d", a->id, a->subid); d_printf (" pall[0].pnr:%d pall_cnt: %d", pall[0].pnr, pall_cnt); }