|
|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|