Beispiel #1
0
int
street_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item)
{
        int country=id_hi & 0xffff;
        int res;
	dbg(1,"enter(%p,%p,0x%x,0x%x,%p)\n", mr, street, id_hi, id_lo, item);
	if (! country)
		return 0;
        tree_search_hv(mr->m->dirname, "street", (id_lo >> 8) | (country << 24), id_lo & 0xff, &res);
	dbg(1,"res=0x%x (blk=0x%x)\n", res, res >> 12);
        block_get_byindex(mr->m->file[mr->current_file], res >> 12, &mr->b);
	street_get_data(street, &mr->b.p);
	street->name_file=mr->m->file[file_strname_stn];
	street->end=mr->b.end;
	street->ref=&mr->b.b->r.lu;
	street->bytes=street_get_bytes(&mr->b.b->r);
	street->str_start=street->str=(struct street_str *)mr->b.p;
	street->coord_begin=mr->b.p;
	street_coord_get_begin(&street->coord_begin);
	street->p=street->coord_begin;
	street->type--;
	item->meth=&street_meth;
	item->priv_data=street;
	street->str+=(res & 0xfff)-1;
	dbg(1,"segid 0x%x\n", street->str[1].segid);
	return street_get(mr, street, item);
#if 0
        mr->b.p=mr->b.block_start+(res & 0xffff);
        return town_get(mr, twn, item);
#endif

	return 0;
}
Beispiel #2
0
static void
tracking_doupdate_lines(struct tracking *tr, struct coord *cc)
{
	int max_dist=1000;
	struct map_selection *sel=route_rect(18, cc, cc, 0, max_dist);
	struct mapset_handle *h;
	struct map *m;
	struct map_rect *mr;
	struct item *item;
	struct street_data *street;
	struct tracking_line *tl;
	struct coord c;

	dbg(1,"enter\n");
        h=mapset_open(tr->ms);
        while ((m=mapset_next(h,1))) {
		mr=map_rect_new(m, sel);
		if (! mr)
			continue;
		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;
			}
		}
		map_rect_destroy(mr);
	}
	mapset_close(h);
	map_selection_destroy(sel);
	dbg(1, "exit\n");
#if 0

	struct transformation t;

	tr->last_ptr=&tr->lines;
	transform_setup_source_rect_limit(&t,c,1000);
	transform_setup_source_rect_limit(&tr->t,c,1000);


	profile_timer(NULL);
	street_get_block(tr->ma,&t,tst_callback,tr);
	profile_timer("end");
#endif
}
Beispiel #3
0
int
street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item)
{
	if (mr->b.p == mr->b.p_start) {
		street_get_data(street, &mr->b.p);
		street->name_file=mr->m->file[file_strname_stn];
		if (mr->cur_sel && street->header->order > limit[mr->cur_sel->order[layer_street]])
			return 0;
		street->end=mr->b.end;
		street->ref=&mr->b.b->r.lu;
		street->bytes=street_get_bytes(&mr->b.b->r);
		street->str_start=street->str=(struct street_str *)mr->b.p;
		street->coord_begin=mr->b.p;
		street_coord_get_begin(&street->coord_begin);
		street->p=street->coord_begin;
		street->type--; 
		item->meth=&street_meth;
		item->priv_data=street;
	} else {
		street->str++;
		street->p=street->next;
	}
	if (! L(street->str->segid))
		return 0;
	if (L(street->str->segid) < 0)
		street->type++;
#if 0
	g_assert(street->p != NULL);
#endif
	street->next=NULL;
	street->status_rewind=street->status=L(street->str[1].segid) >= 0 ? 0:1;
#if 0
	if (street->type->country != 0x31) {
		printf("country=0x%x\n", street->type->country);
	}
#endif
	item->id_hi=street->type->country | (mr->current_file << 16);
	item->id_lo=L(street->str->segid) > 0 ? L(street->str->segid) : -L(street->str->segid);
	switch(street->str->type & 0x1f) {
	case 0xf: /* very small street */
		if (street->str->limit == 0x33) 
			item->type=type_street_nopass;
		else
			item->type=type_street_0;
		break;
	case 0xd:
		item->type=type_ferry;
		break;
	case 0xc: /* small street */
		item->type=type_street_1_city;
		break;
	case 0xb:
		item->type=type_street_2_city;
		break;
	case 0xa:
		if ((street->str->limit == 0x03 || street->str->limit == 0x30) && street->header->order < 4)
			item->type=type_street_4_city;
		else	
			item->type=type_street_3_city;
		break;
	case 0x9:
		if (street->header->order < 5)
			item->type=type_street_4_city;
		else if (street->header->order < 7)
			item->type=type_street_2_city;
		else
			item->type=type_street_1_city;
		break;
	case 0x8:
		item->type=type_street_2_land;
		break;
	case 0x7:
		if ((street->str->limit == 0x03 || street->str->limit == 0x30) && street->header->order < 4)
			item->type=type_street_4_city;
		else
			item->type=type_street_3_land;
		break;
	case 0x6:
		item->type=type_ramp;
		break;
	case 0x5:
		item->type=type_street_4_land;
		break;
	case 0x4:
		item->type=type_street_4_land;
		break;
	case 0x3:
		item->type=type_street_n_lanes;
		break;
	case 0x2:
		item->type=type_highway_city;
		break;
	case 0x1:
		item->type=type_highway_land;
		break;
	default:
		item->type=type_street_unkn;
		dbg(0,"unknown type 0x%x\n",street->str->type);
	}
#if 0
	coord_debug=(street->str->unknown2 != 0x40 || street->str->unknown3 != 0x40);
	if (coord_debug) {
		item->type=type_street_unkn;
		printf("%d %02x %02x %02x %02x\n", street->str->segid, street->str->type, street->str->limit, street->str->unknown2, street->str->unknown3);
	}
#endif
	street->p_rewind=street->p;
	street->name.len=0;
	street->attr_next=attr_label;
	return 1;
}
Beispiel #4
0
int
street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item)
{	
	int *flags;
	struct coord_rect r;
	for (;;) {
		while (street->more) {
			struct coord c;
			street_coord_get(street, &c, 1);
		}
#if 0
		if (street->housenumber) {
			if (street_get_housenumber(mr, street, item))
				return 1;
			street->housenumber=0;
		}
#endif
		if (mr->b.p == mr->b.p_start) {
			street_get_data(street, &mr->b.p);
			street->name_file=mr->m->file[file_strname_stn];
			if (mr->cur_sel && street_header_get_order(street->header) > limit[mr->cur_sel->order])
				return 0;
			street->end=mr->b.end;
			block_get_r(mr->b.b, &r);
			street->ref=r;
			street->bytes=street_get_bytes(&r);
			street->str_start=street->str=(struct street_str *)mr->b.p;
			street->coord_begin=mr->b.p;
			street_coord_get_begin(&street->coord_begin);
			street->p=street->coord_begin;
			street->type--; 
			item->meth=&street_meth;
			item->priv_data=street;
		} else {
			street->str++;
			street->p=street->next;
		}
		if (! street_str_get_segid(street->str))
			return 0;
		if (street_str_get_segid(street->str) < 0)
			street->type++;
#if 0
		dbg_assert(street->p != NULL);
#endif
		street->next=NULL;
		street->status_rewind=street->status=street_str_get_segid(&street->str[1]) >= 0 ? 0:1;
#if 0
		if (street->type->country != 0x31) {
			printf("country=0x%x\n", street->type->country);
		}
#endif
		item->id_hi=street_type_get_country(street->type) | (mr->current_file << 16);
		item->id_lo=street_str_get_segid(street->str) > 0 ? street_str_get_segid(street->str) : -street_str_get_segid(street->str);
		switch(street_str_get_type(street->str) & 0x1f) {
		case 0xf: /* very small street */
			if (street_str_get_limit(street->str) == 0x33) 
				item->type=type_street_nopass;
			else
				item->type=type_street_0;
			break;
		case 0xd:
			item->type=type_ferry;
			break;
		case 0xc: /* small street */
			item->type=type_street_1_city;
			break;
		case 0xb:
			item->type=type_street_2_city;
			break;
		case 0xa:
			if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30) && street_header_get_order(street->header) < 4)
				item->type=type_street_4_city;
			else	
				item->type=type_street_3_city;
			break;
		case 0x9:
			if (street_header_get_order(street->header) < 5)
				item->type=type_street_4_city;
			else if (street_header_get_order(street->header) < 7)
				item->type=type_street_2_city;
			else
				item->type=type_street_1_city;
			break;
		case 0x8:
			item->type=type_street_2_land;
			break;
		case 0x7:
			if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30) && street_header_get_order(street->header) < 4)
				item->type=type_street_4_city;
			else
				item->type=type_street_3_land;
			break;
		case 0x6:
			item->type=type_ramp;
			break;
		case 0x5:
			item->type=type_street_4_land;
			break;
		case 0x4:
			item->type=type_street_4_land;
			break;
		case 0x3:
			item->type=type_street_n_lanes;
			break;
		case 0x2:
			item->type=type_highway_city;
			break;
		case 0x1:
			item->type=type_highway_land;
			break;
		default:
			item->type=type_street_unkn;
			dbg(0,"unknown type 0x%x\n",street_str_get_type(street->str));
		}
		flags=item_get_default_flags(item->type);
		if (flags)
			street->flags=*flags;
		else
			street->flags=0;
		if (street_str_get_type(street->str) & 0x40) {
			street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAYREV:0;
			street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAY:0;
		} else {
			street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAY:0;
			street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAYREV:0;
		}
#if 0
		coord_debug=(street->str->unknown2 != 0x40 || street->str->unknown3 != 0x40);
		if (coord_debug) {
			item->type=type_street_unkn;
			printf("%d %02x %02x %02x %02x\n", street->str->segid, street->str->type, street->str->limit, street->str->unknown2, street->str->unknown3);
		}
#endif
		street->p_rewind=street->p;
		street->name.len=0;
		street->attr_next=attr_label;
		street->more=1;
		street->housenumber=1;
		street->hn_count=0;
		if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) 
			continue;
		item->meth=&street_meth;
		item->priv_data=street;
		return 1;
	}
}