GList * boundary_find_matches(GList *l, struct coord *c) { GList *ret = NULL; //fprintf(stderr,"boundary_find_matches:001\n"); while (l) { //fprintf(stderr,"boundary_find_matches:002\n"); struct boundary *boundary = l->data; if (bbox_contains_coord(&boundary->r, c)) { //fprintf(stderr,"boundary_find_matches:003 id=%lld name=%s\n", item_bin_get_relationid(boundary->ib), osm_tag_name(boundary->ib)); if (geom_poly_segments_point_inside(boundary->sorted_segments, c) > 0) { //fprintf(stderr,"boundary_find_matches:004\n"); ret = g_list_prepend(ret, boundary); } // children stuff disabled!! // ret = g_list_concat(ret, boundary_find_matches(boundary->children, c)); // children stuff disabled!! } l = g_list_next(l); } //fprintf(stderr,"boundary_find_matches:099\n"); return ret; }
GList * boundary_find_matches(GList *l, struct coord *c) { GList *ret=NULL; while (l) { struct boundary *boundary=l->data; if (bbox_contains_coord(&boundary->r, c)) { if (geom_poly_segments_point_inside(boundary->sorted_segments,c) > 0) ret=g_list_prepend(ret, boundary); ret=g_list_concat(ret,boundary_find_matches(boundary->children, c)); } l=g_list_next(l); } return ret; }
GList * boundary_find_matches_level(GList *l, struct coord *c, int min_admin_level, int max_admin_level) { GList *ret = NULL; char *al; int admin_level; struct boundary *boundary = NULL; while (l) { boundary = l->data; al = osm_tag_value(boundary->ib, "admin_level"); if (!al) { admin_level = 9999; } else { admin_level = atoi(al); } if (admin_level < 2) { admin_level = 9999; } //fprintf(stderr, "matches 001:this:%d min:%d max:%d\n", admin_level, min_admin_level, max_admin_level); if ((admin_level >= min_admin_level) && (admin_level <= max_admin_level)) { //fprintf(stderr, "matches 002:level\n"); if (bbox_contains_coord(&boundary->r, c)) { //fprintf(stderr, "matches 003:bbox\n"); if (geom_poly_segments_point_inside(boundary->sorted_segments, c) > 0) { //fprintf(stderr, "matches 004:**found**\n"); ret = g_list_prepend(ret, boundary); } } } l = g_list_next(l); } return ret; }
GList * boundary_find_matches_single(GList *l, struct coord *c) { GList *ret = NULL; if (l) { //fprintf(stderr, "bbox:001\n"); struct boundary *boundary = l->data; //fprintf(stderr, "bbox:%d %d %d %d\n", boundary->r.l.x, boundary->r.l.y, boundary->r.h.x, boundary->r.h.y); //fprintf(stderr, "c:%d %d\n", c->x, c->y); if (bbox_contains_coord(&boundary->r, c)) { //fprintf(stderr, "inside bbox\n"); if (geom_poly_segments_point_inside(boundary->sorted_segments, c) > 0) { //fprintf(stderr, "bbox:002\n"); ret = g_list_prepend(ret, boundary); } } } return ret; }