예제 #1
0
파일: ch.c 프로젝트: PDXostc/navit
void
ch_generate_tiles(char *map_suffix, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info)
{
	struct tile_info info;
	FILE *in,*ref,*ddsg_coords,*ddsg;
	FILE **graphfiles;
        info.write=0;
        info.maxlen=0;
        info.suffix=suffix;
        info.tiles_list=NULL;
        info.tilesdir_out=tilesdir_out;
	graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));

	ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
	in=tempfile(map_suffix,"ways_split",0);
	ref=tempfile(map_suffix,"ways_split_ref",0);
	ddsg_coords=tempfile(suffix,"ddsg_coords",1);
	ddsg=tempfile(suffix,"ddsg",1);
	ch_generate_ddsg(in, ref, ddsg_coords, ddsg);
	fclose(in);
	fclose(ref);
	fclose(ddsg_coords);
	fclose(ddsg);
	ch_generate_sgr(suffix);
	ch_setup(suffix);
	ch_process(graphfiles, ch_levels, 0);
	ch_close_tempfiles(graphfiles, ch_levels);

	tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
	ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
	merge_tiles(&info);

	write_tilesdir(&info, zip_info, tilesdir_out);
}
예제 #2
0
파일: misc.c 프로젝트: Jalakas/navit
static int
phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, FILE **reference, int in_count, int with_range)
{
	int i;

	processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
	bytes_read=0;
	sig_alrm(0);
	if (! info->write)
		tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
	for (i = 0 ; i < in_count ; i++) {
		if (in[i]) {
			if (with_range)
				phase34_process_file_range(info, in[i], reference ? reference[i]:NULL);
			else
				phase34_process_file(info, in[i], reference ? reference[i]:NULL);
		}
	}
	if (! info->write)
		merge_tiles(info);
	sig_alrm(0);
	sig_alrm_end();
	write_tilesdir(info, zip_info, info->tilesdir_out);

	return 0;

}
예제 #3
0
파일: ch.c 프로젝트: PDXostc/navit
void
ch_assemble_map(char *map_suffix, char *suffix, struct zip_info *zip_info)
{
	struct tile_info info;
	struct tile_head *th;
	FILE **graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
	FILE *ref;
	struct item_id id;
	int nodeid=0;

        info.write=1;
        info.maxlen=zip_get_maxnamelen(zip_info);
        info.suffix=suffix;
        info.tiles_list=NULL;
        info.tilesdir_out=NULL;
	ref=tempfile(suffix,"sgr_ref",1);

	create_tile_hash();

	th=tile_head_root;
        while (th) {
		th->zip_data=NULL;
		th->process=1;
                th=th->next;
        }

	ch_setup(suffix);
	ch_copy_to_tiles(suffix, ch_levels, &info, ref);
	fclose(ref);
	ref=tempfile(suffix,"sgr_ref",0);
	sgr_nodes_hash=g_hash_table_new_full(NULL, NULL, NULL, item_id_slice_free);
	while (fread(&id, sizeof(id), 1, ref)) {
		struct item_id *id2=g_slice_new(struct item_id);
		*id2=id;
#if 0
		dbg(lvl_debug,"%d is "ITEM_ID_FMT"\n",nodeid,ITEM_ID_ARGS(*id2));
#endif
		g_hash_table_insert(sgr_nodes_hash, GINT_TO_POINTER(nodeid), id2);
		nodeid++;
	}
	th=tile_head_root;
        while (th) {
		th->zip_data=malloc(th->total_size);
		th->total_size_used=0;
                th=th->next;
        }
	ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
	ch_process(graphfiles, ch_levels, 1);
	ch_close_tempfiles(graphfiles, ch_levels);

	g_hash_table_destroy(newnode_hash);
	g_hash_table_destroy(edge_hash);
	g_hash_table_destroy(sgr_nodes_hash);

	ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
	write_tilesdir(&info, zip_info, NULL);

	th=tile_head_root;
        while (th) {
		if (th->name[0]) {
			if (th->total_size != th->total_size_used) {
				fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
				exit(1);
			}
			write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
		} else {
			fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
		}
		g_free(th->zip_data);
                th=th->next;
        }
}