Beispiel #1
0
void
phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes)
{
	struct map_rect *mr;
	struct item *item;
	int count;
	struct coord ca[phase1_coord_max];
	struct attr attr;
	struct item_bin *item_bin;

	while (maps) {
		mr=map_rect_new(maps->data, NULL);
		while ((item = map_rect_get_item(mr))) {
			count=item_coord_get(item, ca, item->type < type_line ? 1: phase1_coord_max);
			item_bin=init_item(item->type);
			item_bin_add_coord(item_bin, ca, count);
			while (item_attr_get(item, attr_any, &attr)) {
				if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end) {
					attr.u.str=map_convert_string(maps->data, attr.u.str);
					if (attr.u.str) {
						item_bin_add_attr(item_bin, &attr);
						map_convert_free(attr.u.str);
					}
				} else 
					item_bin_add_attr(item_bin, &attr);
			}
			if (item->type >= type_line) 
				item_bin_write(item_bin, out_ways);
			else
				item_bin_write(item_bin, out_nodes);
		}
		map_rect_destroy(mr);
		maps=g_list_next(maps);
	}
}
Beispiel #2
0
void
phase1_map(struct map *map, FILE *out_ways, FILE *out_nodes)
{
	struct map_rect *mr=map_rect_new(map, NULL);
	struct item *item;
	int count,max=16384;
	struct coord ca[max];
	struct attr attr;

	while ((item = map_rect_get_item(mr))) {
		count=item_coord_get(item, ca, item->type < type_line ? 1: max);
		item_bin_init(item_bin, item->type);
		item_bin_add_coord(item_bin, ca, count);
		while (item_attr_get(item, attr_any, &attr)) {
			if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end) {
				attr.u.str=map_convert_string(map, attr.u.str);
				item_bin_add_attr(item_bin, &attr);
				map_convert_free(attr.u.str);
			} else 
				item_bin_add_attr(item_bin, &attr);
		}
		if (item->type >= type_line) 
			item_bin_write(item_bin, out_ways);
		else
			item_bin_write(item_bin, out_nodes);
	}
	map_rect_destroy(mr);
}
Beispiel #3
0
static void
search_list_common_new(struct item *item, struct search_list_common *common)
{
	struct attr attr;
	if (item_attr_get(item, attr_town_name, &attr))
		common->town_name=map_convert_string(item->map, attr.u.str);
	else
		common->town_name=NULL;
	if (item_attr_get(item, attr_county_name, &attr))
		common->county_name=map_convert_string(item->map, attr.u.str);
	else
		common->county_name=NULL;
	if (item_attr_get(item, attr_district_name, &attr))
		common->district_name=map_convert_string(item->map, attr.u.str);
	else
		common->district_name=NULL;
	if (item_attr_get(item, attr_postal, &attr))
		common->postal=map_convert_string(item->map, attr.u.str);
	else if (item_attr_get(item, attr_town_postal, &attr))
		common->postal=map_convert_string(item->map, attr.u.str);
	else
		common->postal=NULL;
	if (item_attr_get(item, attr_postal_mask, &attr))
		common->postal_mask=map_convert_string(item->map, attr.u.str);
	else
		common->postal_mask=NULL;
}
Beispiel #4
0
static struct search_list_town *
search_list_town_new(struct item *item)
{
	struct search_list_town *ret=g_new0(struct search_list_town, 1);
	struct attr attr;
	struct coord c;
	
	ret->itemt=*item;
	if (item_attr_get(item, attr_town_streets_item, &attr)) {
		dbg(1,"town_assoc 0x%x 0x%x\n", attr.u.item->id_hi, attr.u.item->id_lo);
		ret->item=*attr.u.item;
	}
	else
		ret->item=*item;
	if (item_attr_get(item, attr_town_name, &attr))
		ret->name=map_convert_string(item->map,attr.u.str);
	if (item_attr_get(item, attr_town_postal, &attr))
		ret->postal=map_convert_string(item->map,attr.u.str);
	if (item_coord_get(item, &c, 1)) {
		ret->c=g_new(struct coord, 1);
		*(ret->c)=c;
	}
Beispiel #5
0
static struct search_list_town *
search_list_town_new(struct item *item)
{
	struct search_list_town *ret=g_new0(struct search_list_town, 1);
	struct attr attr;
	struct coord c;

	ret->itemt=*item;
	ret->common.item=ret->common.unique=*item;
	if (item_attr_get(item, attr_town_streets_item, &attr)) {
		dbg(1,"town_assoc 0x%x 0x%x\n", attr.u.item->id_hi, attr.u.item->id_lo);
		ret->common.unique=*attr.u.item;
	}
	search_list_common_new(item, &ret->common);
	if (item_attr_get(item, attr_county_name, &attr))
		ret->county=map_convert_string(item->map,attr.u.str);
	else
		ret->county=NULL;
	if (item_coord_get(item, &c, 1)) {
		ret->common.c=g_new(struct pcoord, 1);
		ret->common.c->x=c.x;
		ret->common.c->y=c.y;
		ret->common.c->pro = map_projection(item->map);
	}