Ejemplo n.º 1
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
}
Ejemplo n.º 2
0
void
navit_add_menu_maps(struct navit *this_, struct mapset *ms, struct menu *men)
{
	struct mapset_handle *handle;
	struct map *map;
	struct menu *mmen;

	handle=mapset_open(ms);
	while ((map=mapset_next(handle,0))) {
		char *s=g_strdup_printf("%s:%s", map_get_type(map), map_get_filename(map));
		mmen=menu_add(men, s, menu_type_toggle, navit_map_toggle, this_, map);
		menu_set_toggle(mmen, map_get_active(map));
		g_free(s);
	}
	mapset_close(handle);
}
Ejemplo n.º 3
0
void
navit_init(struct navit *this_)
{
	struct menu *mapmen,*men,*men2;
	struct map *map;
	struct mapset_handle *handle;
	struct mapset *ms=this_->mapsets->data;

	if (this_->menubar) {
		mapmen=menu_add(this_->menubar, "Map", menu_type_submenu, NULL, NULL, NULL);
		// menu_add(map, "Test", menu_type_menu, NULL, NULL);
		men=menu_add(mapmen, "Layout", menu_type_submenu, NULL, NULL, NULL);
		menu_add(men, "Test", menu_type_menu, NULL, NULL, NULL);
		men=menu_add(mapmen, "Projection", menu_type_submenu, NULL, NULL, NULL);
		menu_add(men, "M&G", menu_type_menu, navit_projection_set, this_, (void *)projection_mg);
		menu_add(men, "Garmin", menu_type_menu, navit_projection_set, this_, (void *)projection_garmin);
		handle=mapset_open(ms);
		while ((map=mapset_next(handle,0))) {
			char *s=g_strdup_printf("%s:%s", map_get_type(map), map_get_filename(map));
			men2=menu_add(mapmen, s, menu_type_toggle, navit_map_toggle, this_, map);
			menu_set_toggle(men2, map_get_active(map));
			g_free(s);
		}
		mapset_close(handle);
	}
	{
		struct mapset *ms=this_->mapsets->data;
		struct coord c;
		int pos,flag=0;
		FILE *f;

		char buffer[2048];
		this_->route=route_new(ms);
		this_->navigation=navigation_new(ms);
		dbg(0,"navigation_register_callback(%p, ... %p)\n", this_->navigation, this_);
		navigation_register_callback(this_->navigation, navigation_mode_long, navit_show_roadbook, this_);
#if 1
		this_->track=track_new(ms);
#endif
		men=NULL;
		if (this_->menubar) {
			men=menu_add(this_->menubar, "Route", menu_type_submenu, NULL, NULL, NULL);
			men=menu_add(men, "Former Destinations", menu_type_submenu, NULL, NULL, NULL);
		}
		f=fopen("destination.txt", "r");
		if (f) {
			while (! feof(f) && fgets(buffer, 2048, f)) {
				if ((pos=coord_parse(buffer, projection_mg, &c))) {
					if (buffer[pos] && buffer[pos] != '\n' ) {
						struct coord *cn=g_new(struct coord, 1);
						*cn=c;
						buffer[strlen(buffer)-1]='\0';
						if (men)
							menu_add(men, buffer+pos+1, menu_type_menu, navit_set_destination_menu, this_, cn);
					}
					flag=1;
				}
			}
			fclose(f);
			if (flag)
				route_set_destination(this_->route, &c);
		}
	}
	global_navit=this_;
}
Ejemplo n.º 4
0
static void
navit_window_items_open(struct menu *men, struct navit *this_, struct navit_window_items *nwi)
{
	struct map_selection sel;
	struct coord c,*center;
	struct mapset_handle *h;
	struct map *m;
	struct map_rect *mr;
	struct item *item;
	struct attr attr;
	int idist,dist;
	struct param_list param[5];
	char distbuf[32];
	char dirbuf[32];
	char coordbuf[64];
	
	dbg(0, "distance=%d\n", nwi->distance);
	if (nwi->distance == -1) 
		dist=40000000;
	else
		dist=nwi->distance*1000;
	param[0].name="Distance";
	param[1].name="Direction";
	param[2].name="Type";
	param[3].name="Name";
	param[4].name=NULL;
	sel.next=NULL;
#if 0
	sel.order[layer_town]=18;
	sel.order[layer_street]=18;
	sel.order[layer_poly]=18;
#else
	sel.order[layer_town]=0;
	sel.order[layer_street]=0;
	sel.order[layer_poly]=0;
#endif
	center=transform_center(this_->trans);
	sel.rect.lu.x=center->x-dist;
	sel.rect.lu.y=center->y+dist;
	sel.rect.rl.x=center->x+dist;
	sel.rect.rl.y=center->y-dist;
	dbg(2,"0x%x,0x%x - 0x%x,0x%x\n", sel.rect.lu.x, sel.rect.lu.y, sel.rect.rl.x, sel.rect.rl.y);
	nwi->click=callback_new_2(navit_window_items_click, this_, nwi);
	nwi->win=gui_datawindow_new(this_->gui, nwi->name, nwi->click, NULL);
	h=mapset_open(navit_get_mapset(this_));
        while ((m=mapset_next(h, 1))) {
		dbg(2,"m=%p %s\n", m, map_get_filename(m));
		mr=map_rect_new(m, &sel);
		dbg(2,"mr=%p\n", mr);
		while ((item=map_rect_get_item(mr))) {
			if (item_coord_get(item, &c, 1)) {
				if (coord_rect_contains(&sel.rect, &c) && g_hash_table_lookup(nwi->hash, &item->type)) {
					if (! item_attr_get(item, attr_label, &attr)) 
						attr.u.str="";
					idist=transform_distance(center, &c);
					if (idist < dist) {
						get_direction(dirbuf, transform_get_angle_delta(center, &c, 0), 1);
						param[0].value=distbuf;	
						param[1].value=dirbuf;
						param[2].value=item_to_name(item->type);
						sprintf(distbuf,"%d", idist/1000);
						param[3].value=attr.u.str;
						sprintf(coordbuf, "0x%x,0x%x", c.x, c.y);
						param[4].value=coordbuf;
						datawindow_add(nwi->win, param, 5);
					}
					/* printf("gefunden %s %s %d\n",item_to_name(item->type), attr.u.str, idist/1000); */
				}
				if (item->type >= type_line) 
					while (item_coord_get(item, &c, 1));
			}
		}
		map_rect_destroy(mr);	
	}
	mapset_close(h);
}