예제 #1
0
파일: tile.c 프로젝트: greg42/navit
void
index_submap_add(struct tile_info *info, struct tile_head *th)
{
	int tlen=tile_len(th->name);
	int len=tlen;
	char *index_tile;
	struct rect r;
	struct item_bin *item_bin;

	index_tile=g_alloca(len+1+strlen(info->suffix));
	strcpy(index_tile, th->name);
	if (len > 6)
		len=6;
	else
		len=0;
	index_tile[len]=0;
	strcat(index_tile, info->suffix);
	tile_bbox(th->name, &r, overlap);

	item_bin=init_item(type_submap);
	item_bin_add_coord_rect(item_bin, &r);
	item_bin_add_attr_range(item_bin, attr_order, (tlen > 4)?tlen-4 : 0, 255);
	item_bin_add_attr_int(item_bin, attr_zipfile_ref, th->zipnum);
	tile_write_item_to_tile(info, item_bin, NULL, index_tile);
}
예제 #2
0
파일: tile.c 프로젝트: noradtux/navit-webos
void
write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out)
{
    int idx,len,maxlen;
    GList *next,*tiles_list;
    char **data;
    struct tile_head *th,**last=NULL;

    tiles_list=get_tiles_list();
    info->tiles_list=&tiles_list;
    if (! info->write)
        create_tile_hash_list(tiles_list);
    next=g_list_first(tiles_list);
    last=&tile_head_root;
    maxlen=info->maxlen;
    if (! maxlen) {
        while (next) {
            if (strlen(next->data) > maxlen)
                maxlen=strlen(next->data);
            next=g_list_next(next);
        }
    }
    len=maxlen;
    while (len >= 0) {
#if 0
        fprintf(stderr,"PROGRESS: collecting tiles with len=%d\n", len);
#endif
        next=g_list_first(tiles_list);
        while (next) {
            if (strlen(next->data) == len) {
                th=g_hash_table_lookup(tile_hash, next->data);
                if (!info->write) {
                    *last=th;
                    last=&th->next;
                    th->next=NULL;
                    th->zipnum=zip_get_zipnum(zip_info);
                    fprintf(out,"%s:%d",strlen((char *)next->data)?(char *)next->data:"index",th->total_size);

                    for ( idx = 0; idx< th->num_subtiles; idx++ ) {
                        data= th_get_subtile( th, idx );
                        fprintf(out,":%s", *data);
                    }

                    fprintf(out,"\n");
                }
                if (th->name[strlen(info->suffix)])
                    index_submap_add(info, th);
                zip_add_member(zip_info);
                processed_tiles++;
            }
            next=g_list_next(next);
        }
        len--;
    }
    if (info->suffix[0] && info->write) {
        struct item_bin *item_bin=init_item(type_submap);
        item_bin_add_coord_rect(item_bin, &world_bbox);
        item_bin_add_attr_range(item_bin, attr_order, 0, 255);
        item_bin_add_attr_int(item_bin, attr_zipfile_ref, zip_get_zipnum(zip_info)-1);
        item_bin_write(item_bin, zip_get_index(zip_info));
    }
}