示例#1
0
文件: block.c 项目: PDXostc/navit
int
block_next_lin(struct map_rect_priv *mr)
{
	struct coord_rect r;
	for (;;) {
		block_lin_count++;
		block_mem+=sizeof(struct block *);
		mr->b.block_num++;
		if (! mr->b.block_num) 
			mr->b.p=mr->file->begin+0x2000;
		else
			mr->b.p=mr->b.block_start+block_get_blocks(mr->b.b)*512;
		if (mr->b.p >= mr->file->end) {
			dbg(lvl_debug,"end of blocks %p vs %p\n", mr->b.p, mr->file->end);
			return 0;
		}
		mr->b.block_start=mr->b.p;
		mr->b.b=block_get(&mr->b.p);
		mr->b.p_start=mr->b.p;
		mr->b.end=mr->b.block_start+block_get_size(mr->b.b);
		if (block_get_count(mr->b.b) == -1) {
			dbg(lvl_warning,"empty blocks\n");
			return 0;
		}
		block_get_r(mr->b.b, &r);
		if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->u.c_rect, &r)) {
			block_active_count++;
			block_active_mem+=block_get_blocks(mr->b.b)*512-sizeof(struct block *);
			dbg(lvl_debug,"block ok\n");
			return 1;
		}
		dbg(lvl_info,"block not in cur_sel\n");
	}
}
示例#2
0
文件: poly.c 项目: Jalakas/navit
int
poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item)
{
	struct coord_rect r;

        for (;;) {
                if (mr->b.p >= mr->b.end)
                        return 0;
		if (mr->b.p == mr->b.p_start) {
			poly->poly_num=0;
			poly->subpoly_num=0;
			poly->subpoly_num_all=0;
			poly->poly_next=mr->b.p;
			item->meth=&poly_meth;
		}
		if (poly->poly_num >= block_get_count(mr->b.b))
			return 0;
		if (!poly->subpoly_num) {
			mr->b.p=poly->poly_next;
			item->id_lo=mr->b.p-mr->file->begin;
			poly_get_data(poly, &mr->b.p);
			poly->poly_next=mr->b.p+poly->count_sum*sizeof(struct coord);
			poly->poly_num++;
			r.lu=poly->c[0];
			r.rl=poly->c[1];
			if (mr->cur_sel && (poly->order > mr->cur_sel->order*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
				poly->subpoly_num_all+=poly->polys;
				mr->b.p=poly->poly_next;
				continue;
			}
			switch(poly->type) {
			case 0x13:
				item->type=type_poly_wood;
				break;
			case 0x14:
				item->type=type_poly_town;
				break;
			case 0x15:
				item->type=type_poly_cemetery;
				break;
			case 0x16:
				item->type=type_poly_building;
				break;
			case 0x17:
				item->type=type_poly_museum;
				break;
			case 0x19:
				item->type=type_poly_place;
				break;
			case 0x1b:
				item->type=type_poly_commercial_center;
				break;
			case 0x1e:
				item->type=type_poly_industry;
				break;
			case 0x23:
				/* FIXME: what is this ?*/
				item->type=type_poly_place;
				break;
			case 0x24:
				item->type=type_poly_car_parking;
				break;
			case 0x28:
				item->type=type_poly_airport;
				break;
			case 0x29:
				item->type=type_poly_station;
				break;
			case 0x2d:
				item->type=type_poly_hospital;
				break;
			case 0x2e:
				item->type=type_poly_hospital;
				break;
			case 0x2f:
				item->type=type_poly_university;
				break;
			case 0x30:
				item->type=type_poly_university;
				break;
			case 0x32:
				item->type=type_poly_park;
				break;
			case 0x34:
				item->type=type_poly_sport;
				break;
			case 0x35:
				item->type=type_poly_sport;
				break;
			case 0x37:
				item->type=type_poly_golf_course;
				break;
			case 0x38:
				item->type=type_poly_national_park;
				break;
			case 0x39:
				item->type=type_poly_nature_park;
				break;
			case 0x3c:
				item->type=type_poly_water;
				break;
			case 0xbc:
				item->type=type_water_line;
				break;
			case 0xc3:
				/* FIXME: what is this ?*/
				item->type=type_border_state;
				break;
			case 0xc6:
				item->type=type_border_country;
				break;
			case 0xc7:
				item->type=type_border_state;
				break;
			case 0xd0:
				item->type=type_rail;
				break;
			default:
				dbg(0,"Unknown poly type 0x%x '%s' 0x%x,0x%x\n", poly->type,poly->name,r.lu.x,r.lu.y);
				item->type=type_street_unkn;
			}
			if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) {
				poly->subpoly_num_all+=poly->polys;
				mr->b.p=poly->poly_next;
				continue;
			}
		} else 
			mr->b.p=poly->subpoly_next;
		dbg(1,"%d %d %s\n", poly->subpoly_num_all, mr->b.block_num, poly->name);
		item->id_lo=poly->subpoly_num_all | (mr->b.block_num << 16);
		item->id_hi=(mr->current_file << 16);
		dbg(1,"0x%x 0x%x\n", item->id_lo, item->id_hi);
		poly->subpoly_next=mr->b.p+L(poly->count[poly->subpoly_num])*sizeof(struct coord);
		poly->subpoly_num++;
		poly->subpoly_num_all++;
		if (poly->subpoly_num >= poly->polys) 
			poly->subpoly_num=0;
		poly->subpoly_start=poly->p=mr->b.p;
		item->priv_data=poly;
		poly->attr_next=attr_label;
		return 1;
        }
}