struct coord ca[max];
struct attr attr;
struct map_selection *sel;
- struct coord_rect r;
pro=map_projection(m);
conv=map_requires_conversion(m);
if (item->id_hi != 0xb0031 || item->id_lo != 0x20c9aeea)
continue;
#endif
- count=item_coord_get_with_bbox(item, ca, item->type < type_line ? 1: max, &r);
+ count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, sel);
+ if (! count)
+ continue;
if (item->type >= type_line && count < 2) {
dbg(1,"poly from map has only %d points\n", count);
continue;
}
- if (! map_selection_contains_rect(sel, &r))
- continue;
if (item->type < type_line) {
#if 0
if (! map_selection_contains_point(sel, &ca[0])) {
#endif
}
if (count == max)
- dbg(0,"point count overflow\n", count);
+ dbg(0,"point count overflow %d\n", count);
if (!item_attr_get(item, attr_label, &attr))
attr.u.str=NULL;
if (conv && attr.u.str && attr.u.str[0]) {
}
int
-item_coord_get_with_bbox(struct item *it, struct coord *c, int count, struct coord_rect *r)
+item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel)
{
int i,ret=it->meth->item_coord_get(it->priv_data, c, count);
- struct coord_rect r2;
- if (ret <= 0)
+ struct coord_rect r;
+ struct map_selection *curr;
+ if (ret <= 0 || !sel)
return ret;
- if (ret == 1) {
- r->rl=r->lu=c[0];
- return ret;
- }
- r2.lu=c[0];
- r2.rl=c[0];
+ r.lu=c[0];
+ r.rl=c[0];
for (i = 1 ; i < ret ; i++) {
- if (r2.lu.x > c[i].x)
- r2.lu.x=c[i].x;
- if (r2.rl.x < c[i].x)
- r2.rl.x=c[i].x;
- if (r2.rl.y > c[i].y)
- r2.rl.y=c[i].y;
- if (r2.lu.y < c[i].y)
- r2.lu.y=c[i].y;
+ if (r.lu.x > c[i].x)
+ r.lu.x=c[i].x;
+ if (r.rl.x < c[i].x)
+ r.rl.x=c[i].x;
+ if (r.rl.y > c[i].y)
+ r.rl.y=c[i].y;
+ if (r.lu.y < c[i].y)
+ r.lu.y=c[i].y;
}
- *r=r2;
- return ret;
+ curr=sel;
+ while (curr) {
+ struct coord_rect *sr=&curr->u.c_rect;
+ if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
+ r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
+ return ret;
+ curr=curr->next;
+ }
+ return 0;
}
int
struct coord;
struct item;
struct item_hash;
+struct map_selection;
void item_coord_rewind(struct item *it);
int item_coord_get(struct item *it, struct coord *c, int count);
-int item_coord_get_with_bbox(struct item *it, struct coord *c, int count, struct coord_rect *r);
+int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection pro);
/* does the next returned coordinate mark a node */
int item_coord_is_node(struct item *it);
tl->angle[i]=transform_get_angle_delta(&sd->c[i], &sd->c[i+1], 0);
}
+static int
+street_data_within_selection(struct street_data *sd, struct map_selection *sel)
+{
+ struct coord_rect r;
+ struct map_selection *curr;
+ int i;
+
+ if (!sel)
+ return 1;
+ r.lu=sd->c[0];
+ r.rl=sd->c[0];
+ for (i = 1 ; i < sd->count ; i++) {
+ if (r.lu.x > sd->c[i].x)
+ r.lu.x=sd->c[i].x;
+ if (r.rl.x < sd->c[i].x)
+ r.rl.x=sd->c[i].x;
+ if (r.rl.y > sd->c[i].y)
+ r.rl.y=sd->c[i].y;
+ if (r.lu.y < sd->c[i].y)
+ r.lu.y=sd->c[i].y;
+ }
+ curr=sel;
+ while (curr) {
+ struct coord_rect *sr=&curr->u.c_rect;
+ if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
+ r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
+ return 1;
+ curr=curr->next;
+ }
+ return 0;
+}
+
+
static void
tracking_doupdate_lines(struct tracking *tr, struct pcoord *pc)
{
while ((item=map_rect_get_item(mr))) {
if (item->type >= type_street_0 && item->type <= type_ferry) {
street=street_get_data(item);
- tl=g_malloc(sizeof(struct tracking_line)+(street->count-1)*sizeof(int));
- tl->street=street;
- tracking_get_angles(tl);
- tl->next=tr->lines;
- tr->lines=tl;
+ if (street_data_within_selection(street, sel)) {
+ tl=g_malloc(sizeof(struct tracking_line)+(street->count-1)*sizeof(int));
+ tl->street=street;
+ tracking_get_angles(tl);
+ tl->next=tr->lines;
+ tr->lines=tl;
+ } else
+ street_data_free(street);
}
}
map_selection_destroy(sel);