adding max subid to areas..

master
steffen 13 years ago
parent 5d5fefe138
commit 48a81d7683

@ -1179,15 +1179,16 @@ struct s_osmareapnt {
}; };
#define MAX_SUBID 100
int osm_area_split_add (struct s_osmmarea *marea) { int osm_area_split_add (struct s_osmmarea *marea) {
/* allocate enought memory */ /* allocate enought memory */
struct map_area *a = NULL; struct map_area *a = NULL;
struct s_osmareapnt *pall = ml_malloc (sizeof (struct s_osmareapnt) * marea->marea->p_cnt); struct s_osmareapnt *pall = ml_malloc (sizeof (struct s_osmareapnt) * marea->marea->p_cnt);
int pall_cnt = marea->marea->p_cnt; int pall_cnt = marea->marea->p_cnt;
int i, j, c, k, smaller; 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; // else return 1;
// d_printf ("marea: %lld cnt:%d", marea->marea->id, marea->marea->p_cnt); // d_printf ("marea: %lld cnt:%d", marea->marea->id, marea->marea->p_cnt);
// map_area_add (marea->marea, MHLOAD_RELOAD); // map_area_add (marea->marea, MHLOAD_RELOAD);
@ -1213,7 +1214,7 @@ int osm_area_split_add (struct s_osmmarea *marea) {
} }
pall_cnt = c; 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 /* j - will keep first ptr to start checking polygon
* c - counter how many angles > 180° */ * c - counter how many angles > 180° */
// d_printf ("**************** subid:%d pallcnt:%d", a->subid, pall_cnt); // 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; i_old = s = i;
angle_old = angle = 0.0; 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° */ /* loop as long as angle is increasing and below 180° */
for (; i != j && angle_old <= angle && angle <= M_PI;) { 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", // 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); // j, i, s, k, angle, angle_old, pall[i].angle);
// /* last visible point */ /* last visible point */
// if (pall[i].angle > M_PI) { if (pall[i].angle > M_PI) {
// if (_debug) d_printf ("added %d pnr:%d", k, pall[i].pnr); // if (_debug) d_printf ("added %d pnr:%d", k, pall[i].pnr);
// a->p[k++] = marea->marea->p[pall[i].pnr]; /* copy point */ a->p[k++] = marea->marea->p[pall[i].pnr]; /* copy point */
// } }
// else else
if (angle_old > angle) { if (angle_old > angle) {
pall[i_old].pnr = pnr_old; pall[i_old].pnr = pnr_old;
} }
@ -1340,10 +1341,14 @@ int osm_area_split_add (struct s_osmmarea *marea) {
pall_cnt = k; 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 (_debug) d_printf ("j:%d c:%d", j, c);
if (pall[0].pnr >= 0 && pall_cnt > 0) { if (pall[0].pnr >= 0 && pall_cnt > 0) {
d_printf ("%s:%d osm_area_split_add: something went very wrong", __FILE__, __LINE__); 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); d_printf (" pall[0].pnr:%d pall_cnt: %d", pall[0].pnr, pall_cnt);
} }

Loading…
Cancel
Save