/[zanavi_public1]/navit/navit/navit.c
ZANavi

Diff of /navit/navit/navit.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 29 Revision 30
119static void navit_cmd_zoom_to_route(struct navit *this); 119static void navit_cmd_zoom_to_route(struct navit *this);
120static void navit_cmd_set_center_cursor(struct navit *this_); 120static void navit_cmd_set_center_cursor(struct navit *this_);
121static void navit_cmd_announcer_toggle(struct navit *this_); 121static void navit_cmd_announcer_toggle(struct navit *this_);
122static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv); 122static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv);
123 123
124int allow_gui_internal = 0; 124int allow_gui_internal = 0; // disable old GUI internal. it will not work anymore!
125int routing_mode = 0; 125int routing_mode = 0;
126int MYSTERY_SPEED = 2; 126int MYSTERY_SPEED = 2;
127int offline_search_filter_duplicates = 0; 127int offline_search_filter_duplicates = 0;
128int offline_search_break_searching = 0; 128int offline_search_break_searching = 0;
129char *navit_maps_dir; 129char *navit_maps_dir;
136int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!) 136int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!)
137int global_search_street_size_factor = 1; // make search radius for streets bigger 137int global_search_street_size_factor = 1; // make search radius for streets bigger
138int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources) 138int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources)
139int enable_water_from_relations = 1; // do you want to draw water where the "tags" come from osm-"relations" 139int enable_water_from_relations = 1; // do you want to draw water where the "tags" come from osm-"relations"
140int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing 140int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing
141int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still
141 142
142long long draw_lines_count_2 = 0; 143long long draw_lines_count_2 = 0;
143long long draw_lines_count_3 = 0; 144long long draw_lines_count_3 = 0;
144long long draw_lines_count_4 = 0; 145long long draw_lines_count_4 = 0;
145 146
146int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads] 147int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads]
147int cur_mapdraw_time_index = 0; 148int cur_mapdraw_time_index = 0;
149
150int route_status_previous = 0;
148 151
149void navit_add_mapset(struct navit *this_, struct mapset *ms) 152void navit_add_mapset(struct navit *this_, struct mapset *ms)
150{ 153{
151#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 154#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
152 dbg(0,"+#+:enter\n"); 155 dbg(0,"+#+:enter\n");
220void navit_draw_async(struct navit *this_, int async) 223void navit_draw_async(struct navit *this_, int async)
221{ 224{
222#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 225#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
223 dbg(0,"+#+:enter\n"); 226 dbg(0,"+#+:enter\n");
224#endif 227#endif
228
229 //dbg(0,"DO__DRAW:ndasync enter, async=%d\n", async);
230
225 //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked); 231 //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked);
226 if (this_->blocked) 232 if (this_->blocked)
227 { 233 {
228 this_->blocked |= 2; 234 this_->blocked |= 2;
229 //dbg(0,"set this_->blocked=%d\n",this_->blocked); 235 //dbg(0,"set this_->blocked=%d\n",this_->blocked);
236 // dbg(0,"DO__DRAW:ndasync return 001\n");
230 return; 237 return;
231 } 238 }
232 transform_setup_source_rect(this_->trans); 239 transform_setup_source_rect(this_->trans);
233 //dbg(0,"call graphics_draw\n"); 240 //dbg(0,"call graphics_draw\n");
241
242 // dbg(0,"DO__DRAW:gras_draw call\n");
234 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1); 243 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1);
244 // dbg(0,"DO__DRAW:ndasync leave\n");
235} 245}
236 246
237void navit_draw(struct navit *this_) 247void navit_draw(struct navit *this_)
238{ 248{
239#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 249#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
240 dbg(0,"+#+:enter\n"); 250 dbg(0,"+#+:enter\n");
241#endif 251#endif
252
253 // dbg(0,"DO__DRAW:nd:enter\n");
242 254
243 //dbg(0,"EEnter this_->ready=%d\n",this_->ready); 255 //dbg(0,"EEnter this_->ready=%d\n",this_->ready);
244 if (this_->ready == 3) 256 if (this_->ready == 3)
245 { 257 {
246 //dbg(0,"navit_draw_async_001\n"); 258 //dbg(0,"navit_draw_async_001\n");
259 // dbg(0,"DO__DRAW:navit_draw_async call\n");
247 navit_draw_async(this_, 0); 260 navit_draw_async(this_, 0);
248 } 261 }
262
263 // dbg(0,"DO__DRAW:nd:leave\n");
249} 264}
250 265
251int navit_get_ready(struct navit *this_) 266int navit_get_ready(struct navit *this_)
252{ 267{
253#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 268#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
255#endif 270#endif
256 ////DBG dbg(0,"EEnter\n"); 271 ////DBG dbg(0,"EEnter\n");
257 return this_->ready; 272 return this_->ready;
258} 273}
259 274
275// UNUSED -----
276// UNUSED -----
260void navit_draw_displaylist(struct navit *this_) 277void navit_draw_displaylist(struct navit *this_)
261{ 278{
262#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 279#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
263 dbg(0,"+#+:enter\n"); 280 dbg(0,"+#+:enter\n");
264#endif 281#endif
307{ 324{
308#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 325#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
309 dbg(0,"+#+:enter\n"); 326 dbg(0,"+#+:enter\n");
310#endif 327#endif
311 328
312 ////DBG dbg(0,"EEnter\n"); 329 //dbg(0,"enter\n");
313 int updated; 330 int updated;
314 331
315 if ((this_->route) && (this_->route->route_status_was_updated == 1)) 332 if ((this_->route) && (this_->route->route_status_was_updated == 1))
316 { 333 {
317 this_->route->route_status_was_updated = 0; 334 this_->route->route_status_was_updated = 0;
360{ 377{
361#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 378#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
362 dbg(0,"+#+:enter\n"); 379 dbg(0,"+#+:enter\n");
363#endif 380#endif
364 381
365 dbg(0,"EEnter\n"); 382 // dbg(0, "EEnter %p\n", this_);
366 struct map_selection sel; 383 struct map_selection sel;
367 int callback = (this_->ready == 1); 384 int callback = (this_->ready == 1);
368 dbg(0,"pre this_->ready=%d\n",this_->ready); 385 // dbg(0, "pre this_->ready=%d\n", this_->ready);
369 this_->ready = this_->ready | 2; 386 this_->ready = this_->ready | 2;
370 dbg(0,"set this_->ready=%d\n",this_->ready); 387 // dbg(0, "set this_->ready=%d\n", this_->ready);
371 memset(&sel, 0, sizeof(sel)); 388 memset(&sel, 0, sizeof(sel));
372 this_->w = w; 389 this_->w = w;
373 this_->h = h; 390 this_->h = h;
374 sel.u.p_rect.rl.x = w; 391 sel.u.p_rect.rl.x = w;
375 sel.u.p_rect.rl.y = h; 392 sel.u.p_rect.rl.y = h;
381 //DBG dbg(0,"callback do\n"); 398 //DBG dbg(0,"callback do\n");
382 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); 399 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
383 } 400 }
384 if (this_->ready == 3) 401 if (this_->ready == 3)
385 { 402 {
386 dbg(0,"navit_draw_async_002\n"); 403 // dbg(0, "navit_draw_async_002\n");
387 // navit_draw_async(this_, 1); 404 // navit_draw_async(this_, 1);
405 // dbg(0,"DO__DRAW:navit_draw_async call\n");
388 navit_draw_async(this_, 0); 406 navit_draw_async(this_, 0);
389 } 407 }
408
409 // dbg(0, "return\n");
390} 410}
391 411
392void navit_resize(void *data, int w, int h) 412void navit_resize(void *data, int w, int h)
393{ 413{
394#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 414#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
489#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 509#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
490 dbg(0,"+#+:enter\n"); 510 dbg(0,"+#+:enter\n");
491#endif 511#endif
492 512
493 // --------- DISABLE ----------- 513 // --------- DISABLE -----------
494 // --------- DISABLE -----------
495 // --------- DISABLE -----------
496 // --------- DISABLE -----------
497 return; 514 return;
498 // --------- DISABLE ----------- 515 // --------- DISABLE -----------
499 // --------- DISABLE -----------
500 // --------- DISABLE -----------
501 // --------- DISABLE -----------
502
503
504 ////DBG dbg(0,"EEnter\n");
505 struct attr follow;
506 follow.type = attr_follow;
507 follow.u.num = this_->center_timeout;
508 navit_set_attr(this_, &follow);
509} 516}
510 517
511int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback) 518int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
512{ 519{
513#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 520#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
533 this_->button_pressed = 1; 540 this_->button_pressed = 1;
534 this_->moved = 0; 541 this_->moved = 0;
535 this_->popped = 0; 542 this_->popped = 0;
536 // ---- DISBALED -------- 543 // ---- DISBALED --------
537 /* 544 /*
538 if (popup_callback) 545 if (popup_callback)
539 this_->button_timeout = event_add_timeout(500, 0, popup_callback); 546 this_->button_timeout = event_add_timeout(500, 0, popup_callback);
540 */ 547 */
541 } 548 }
542 if (button == 2) 549 if (button == 2)
543 navit_set_center_screen(this_, p, 1); 550 navit_set_center_screen(this_, p, 1);
544 if (button == 3) 551 if (button == 3)
545 popup(this_, button, p); 552 popup(this_, button, p);
606 if (!this->ignore_graphics_events) 613 if (!this->ignore_graphics_events)
607 { 614 {
608 if (!this->popup_callback) 615 if (!this->popup_callback)
609 { 616 {
610 this->popup_callback = callback_new_1(callback_cast(navit_popup), this); 617 this->popup_callback = callback_new_1(callback_cast(navit_popup), this);
618 callback_add_names(this->popup_callback, "navit_button", "navit_popup");
611 } 619 }
612 navit_handle_button(this, pressed, button, p, this->popup_callback); 620 navit_handle_button(this, pressed, button, p, this->popup_callback);
613 } 621 }
614} 622}
615 623
624// UNUSED ---
625// UNUSED ---
616static void navit_motion_timeout(struct navit *this_) 626static void navit_motion_timeout(struct navit *this_)
617{ 627{
618#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 628#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
619 dbg(0,"+#+:enter\n"); 629 dbg(0,"+#+:enter\n");
620#endif 630#endif
621 ////DBG dbg(0,"EEnter\n"); 631 // dbg(0,"EEnter\n");
622 int dx, dy; 632 int dx, dy;
623 633
624 if (this_->drag_bitmap) 634 if (this_->drag_bitmap)
625 { 635 {
626 struct point point; 636 struct point point;
652 update_transformation(tr, &this_->pressed, &this_->current, NULL); 662 update_transformation(tr, &this_->pressed, &this_->current, NULL);
653#endif 663#endif
654#if 0 664#if 0
655 graphics_displaylist_move(this_->displaylist, dx, dy); 665 graphics_displaylist_move(this_->displaylist, dx, dy);
656#endif 666#endif
657 graphics_draw_cancel(this_->gra, this_->displaylist); 667 graphics_draw_cancel(this_->gra, this_->displaylist); // --> calls "do_draw" normally
658 // //DBG dbg(0,"call graphics_displaylist_draw 1")
659 graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags); 668 graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags);
669
660 transform_destroy(tr); 670 transform_destroy(tr);
661 this_->moved = 1; 671 this_->moved = 1;
662 } 672 }
663 this_->motion_timeout = NULL; 673 this_->motion_timeout = NULL;
664 return; 674 return;
688 698
689 // -------- DISABLE ------- 699 // -------- DISABLE -------
690 // -------- DISABLE ------- 700 // -------- DISABLE -------
691 // -------- DISABLE ------- 701 // -------- DISABLE -------
692 /* 702 /*
693 if (!this_->motion_timeout_callback) 703 if (!this_->motion_timeout_callback)
694 this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_); 704 this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_);
695 if (!this_->motion_timeout) 705 if (!this_->motion_timeout)
696 this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback); 706 this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback);
697 */ 707 */
698 // -------- DISABLE ------- 708 // -------- DISABLE -------
699 // -------- DISABLE ------- 709 // -------- DISABLE -------
700 // -------- DISABLE ------- 710 // -------- DISABLE -------
701 } 711 }
702 } 712 }
939 dbg(0,"+#+:enter\n"); 949 dbg(0,"+#+:enter\n");
940#endif 950#endif
941 //DBG dbg(0,"EEnter\n"); 951 //DBG dbg(0,"EEnter\n");
942 long scale = transform_get_scale(this_->trans); 952 long scale = transform_get_scale(this_->trans);
943 long new_scale_long = new_scale; 953 long new_scale_long = new_scale;
944 dbg(0, "zoom to scale -> old scale=%d", scale); 954 // dbg(0, "zoom to scale -> old scale=%d", scale);
945 dbg(0, "zoom to scale -> want scale=%d", new_scale_long); 955 // dbg(0, "zoom to scale -> want scale=%d", new_scale_long);
946 956
947 // only do something if scale changed! 957 // only do something if scale changed!
948 if (scale != new_scale_long) 958 if (scale != new_scale_long)
949 { 959 {
950 navit_scale(this_, new_scale_long, p, 1); 960 navit_scale(this_, new_scale_long, p, 1);
1658 g_free(argv[i]); 1668 g_free(argv[i]);
1659 g_free(argv); 1669 g_free(argv);
1660 } 1670 }
1661} 1671}
1662 1672
1663static struct command_table commands[] = 1673static struct command_table
1664{ 1674 commands[] =
1665{ "zoom_in", command_cast(navit_cmd_zoom_in) }, 1675 { { "zoom_in", command_cast(navit_cmd_zoom_in) }, { "zoom_out", command_cast(navit_cmd_zoom_out) }, { "zoom_to_route", command_cast(navit_cmd_zoom_to_route) }, { "say", command_cast(navit_cmd_say) }, { "set_center_cursor", command_cast(navit_cmd_set_center_cursor) }, { "set_destination", command_cast(navit_cmd_set_destination) }, { "announcer_toggle", command_cast(navit_cmd_announcer_toggle) }, { "fmt_coordinates", command_cast(navit_cmd_fmt_coordinates) }, { "set_int_var", command_cast(navit_cmd_set_int_var) }, { "get_int_var", command_cast(navit_cmd_get_int_var) }, { "push_int", command_cast(navit_cmd_push_int) }, { "pop_int", command_cast(navit_cmd_pop_int) }, { "int_stack_size", command_cast(navit_cmd_int_stack_size) }, { "toggle_layer", command_cast(navit_cmd_toggle_layer) }, { "strjoin", command_cast(navit_cmd_strjoin) }, { "spawn", command_cast(navit_cmd_spawn) }, { "map_add_curr_pos", command_cast(navit_cmd_map_add_curr_pos) }, { "map_item_set_attr", command_cast(navit_cmd_map_item_set_attr) }, { "set_attr_var", command_cast(navit_cmd_set_attr_var) }, { "get_attr_var", command_cast(navit_cmd_get_attr_var) }, };
1666{ "zoom_out", command_cast(navit_cmd_zoom_out) },
1667{ "zoom_to_route", command_cast(navit_cmd_zoom_to_route) },
1668{ "say", command_cast(navit_cmd_say) },
1669{ "set_center_cursor", command_cast(navit_cmd_set_center_cursor) },
1670{ "set_destination", command_cast(navit_cmd_set_destination) },
1671{ "announcer_toggle", command_cast(navit_cmd_announcer_toggle) },
1672{ "fmt_coordinates", command_cast(navit_cmd_fmt_coordinates) },
1673{ "set_int_var", command_cast(navit_cmd_set_int_var) },
1674{ "get_int_var", command_cast(navit_cmd_get_int_var) },
1675{ "push_int", command_cast(navit_cmd_push_int) },
1676{ "pop_int", command_cast(navit_cmd_pop_int) },
1677{ "int_stack_size", command_cast(navit_cmd_int_stack_size) },
1678{ "toggle_layer", command_cast(navit_cmd_toggle_layer) },
1679{ "strjoin", command_cast(navit_cmd_strjoin) },
1680{ "spawn", command_cast(navit_cmd_spawn) },
1681{ "map_add_curr_pos", command_cast(navit_cmd_map_add_curr_pos) },
1682{ "map_item_set_attr", command_cast(navit_cmd_map_item_set_attr) },
1683{ "set_attr_var", command_cast(navit_cmd_set_attr_var) },
1684{ "get_attr_var", command_cast(navit_cmd_get_attr_var) }, };
1685 1676
1686void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) 1677void navit_command_add_table(struct navit*this_, struct command_table *commands, int count)
1687{ 1678{
1688#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1679#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1689 dbg(0,"+#+:enter\n"); 1680 dbg(0,"+#+:enter\n");
1696navit_new(struct attr *parent, struct attr **attrs) 1687navit_new(struct attr *parent, struct attr **attrs)
1697{ 1688{
1698#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1689#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1699 dbg(0,"+#+:enter\n"); 1690 dbg(0,"+#+:enter\n");
1700#endif 1691#endif
1701 ////DBG dbg(0,"EEnter\n"); 1692
1702 struct navit *this_=g_new0(struct navit, 1); 1693 struct navit *this_=g_new0(struct navit, 1);
1703 struct pcoord center; 1694 struct pcoord center;
1704 struct coord co; 1695 struct coord co;
1705 struct coord_geo g; 1696 struct coord_geo g;
1706 enum projection pro = projection_mg; 1697 enum projection pro = projection_mg;
1727 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3; 1718 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3;
1728 this_->follow_cursor = 1; 1719 this_->follow_cursor = 1;
1729 this_->radius = 30; 1720 this_->radius = 30;
1730 this_->border = 16; 1721 this_->border = 16;
1731 1722
1723 // dbg(0, "GGGGG:set global_navit\n");
1724 global_navit = this_;
1725
1732 this_->trans = transform_new(); 1726 this_->trans = transform_new();
1733 this_->trans_cursor = transform_new(); 1727 this_->trans_cursor = transform_new();
1734 transform_from_geo(pro, &g, &co); 1728 transform_from_geo(pro, &g, &co);
1735 center.x = co.x; 1729 center.x = co.x;
1736 center.y = co.y; 1730 center.y = co.y;
1812 if (this_->gra) 1806 if (this_->gra)
1813 return 0; 1807 return 0;
1814 this_->gra = gra; 1808 this_->gra = gra;
1815 1809
1816 /* 1810 /*
1817 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_); 1811 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_);
1818 graphics_add_callback(gra, this_->resize_callback); 1812 graphics_add_callback(gra, this_->resize_callback);
1819 this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_); 1813 this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_);
1820 graphics_add_callback(gra, this_->button_callback); 1814 graphics_add_callback(gra, this_->button_callback);
1821 this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_); 1815 this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_);
1822 graphics_add_callback(gra, this_->motion_callback); 1816 graphics_add_callback(gra, this_->motion_callback);
1823 */ 1817 */
1824 1818
1825 // this draw the vehicle // very stupid 1819 // this draw the vehicle // very stupid
1826 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_); 1820 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_);
1821 callback_add_names(this_->predraw_callback, "navit_set_graphics", "navit_predraw");
1827 graphics_add_callback(gra, this_->predraw_callback); 1822 graphics_add_callback(gra, this_->predraw_callback);
1828 1823
1829 ////DBG dbg(0,"111111111\n"); 1824 ////DBG dbg(0,"111111111\n");
1830 return 1; 1825 return 1;
1831} 1826}
2643 active.u.num = 0; 2638 active.u.num = 0;
2644 //map_set_attr(map2, &active); 2639 //map_set_attr(map2, &active);
2645 } 2640 }
2646 g_free(map_file); 2641 g_free(map_file);
2647 2642
2648
2649
2650
2651
2652
2653 // gpx tracks map -------------------- 2643 // gpx tracks map --------------------
2654 parent.type = attr_navit; 2644 parent.type = attr_navit;
2655 parent.u.navit = this_; 2645 parent.u.navit = this_;
2656 type.type = attr_type; 2646 type.type = attr_type;
2657 type.u.str = "textfile"; 2647 type.u.str = "textfile";
2706 active.u.num = 0; 2696 active.u.num = 0;
2707 //map_set_attr(map2, &active); 2697 //map_set_attr(map2, &active);
2708 } 2698 }
2709 g_free(map_file); 2699 g_free(map_file);
2710 // traffic map -------------------- 2700 // traffic map --------------------
2711
2712
2713
2714
2715
2716 2701
2717 2702
2718 int i = 1; 2703 int i = 1;
2719 for (i = 1; i < 10; i++) 2704 for (i = 1; i < 10; i++)
2720 { 2705 {
2809 mapset_close(msh); 2794 mapset_close(msh);
2810 } 2795 }
2811 */ 2796 */
2812 2797
2813 /* 2798 /*
2814 struct attr parent; 2799 struct attr parent;
2815 parent.type = attr_navit; 2800 parent.type = attr_navit;
2816 parent.u.navit = global_navit; 2801 parent.u.navit = global_navit;
2817 2802
2818 struct attr *attrs_r[2]; 2803 struct attr *attrs_r[2];
2819 attrs_r[0] = NULL; 2804 attrs_r[0] = NULL;
2820 attrs_r[1] = NULL; 2805 attrs_r[1] = NULL;
2821 */ 2806 */
2822 2807
2823 //***this_->route = route_new(&parent, attrs_r); 2808 //***this_->route = route_new(&parent, attrs_r);
2824 2809
2825 2810
2826 //int async = 0; 2811 //int async = 0;
2838 ms = this_->mapsets->data; 2823 ms = this_->mapsets->data;
2839 route_set_mapset(this_->route, ms); 2824 route_set_mapset(this_->route, ms);
2840 2825
2841 struct attr callback; 2826 struct attr callback;
2842 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 2827 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
2828 callback_add_names(this_->route_cb, "navit_add_all_maps", "navit_redraw_route");
2843 callback.type = attr_callback; 2829 callback.type = attr_callback;
2844 callback.u.callback = this_->route_cb; 2830 callback.u.callback = this_->route_cb;
2845 route_add_attr(this_->route, &callback); 2831 route_add_attr(this_->route, &callback);
2846 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans)); 2832 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans));
2847 } 2833 }
2883 struct mapset *ms; 2869 struct mapset *ms;
2884 struct map *map; 2870 struct map *map;
2885 int callback; 2871 int callback;
2886 char *center_file; 2872 char *center_file;
2887 2873
2874 // dbg(0,"GGGGG:set global_navit\n");
2875 // global_navit = this_;
2876
2888 // default value 2877 // default value
2889 navit_maps_dir = "/sdcard/zanavi/maps/"; 2878 navit_maps_dir = "/sdcard/zanavi/maps/";
2890 2879
2891 global_img_waypoint = NULL; 2880 global_img_waypoint = NULL;
2892 2881
2911 if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) 2900 if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra))
2912 { 2901 {
2913 struct attr attr_type_gui, attr_type_graphics; 2902 struct attr attr_type_gui, attr_type_graphics;
2914 gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL); 2903 gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL);
2915 graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL); 2904 graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL);
2916 //DBG dbg(0, "failed to connect graphics '%s' to gui '%s'\n", attr_type_graphics.u.str, attr_type_gui.u.str);
2917 // //DBG dbg(0," Please see http://wiki.navit-project.org/index.php/Failed_to_connect_graphics_to_gui\n");
2918 // //DBG dbg(0," for explanations and solutions\n");
2919 2905
2920 dbg(0, "failed to connect to graphics\n"); 2906 dbg(0, "failed to connect to graphics\n");
2921 navit_destroy(this_); 2907 navit_destroy(this_);
2922 return; 2908 return;
2923 } 2909 }
3026 3012
3027 if (this_->route) 3013 if (this_->route)
3028 { 3014 {
3029 struct attr callback; 3015 struct attr callback;
3030 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 3016 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
3017 callback_add_names(this_->route_cb, "navit_init", "navit_redraw_route");
3031 callback.type = attr_callback; 3018 callback.type = attr_callback;
3032 callback.u.callback = this_->route_cb; 3019 callback.u.callback = this_->route_cb;
3033 route_add_attr(this_->route, &callback); 3020 route_add_attr(this_->route, &callback);
3034 } 3021 }
3035 3022
3036 if (this_->navigation) 3023 if (this_->navigation)
3037 { 3024 {
3038 if (this_->speech) 3025 if (this_->speech)
3039 { 3026 {
3040 this_->nav_speech_cb = callback_new_1(callback_cast(navit_speak), this_); 3027 this_->nav_speech_cb = callback_new_1(callback_cast(navit_speak), this_);
3028 callback_add_names(this_->nav_speech_cb, "navit_init", "navit_speak");
3041 navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb); 3029 navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb);
3042 } 3030 }
3043 3031
3044 if (this_->route) 3032 if (this_->route)
3045 { 3033 {
3050 dbg(0, "Setting Center\n"); 3038 dbg(0, "Setting Center\n");
3051 center_file = bookmarks_get_center_file(FALSE); 3039 center_file = bookmarks_get_center_file(FALSE);
3052 //dbg(0, "g0\n"); 3040 //dbg(0, "g0\n");
3053 bookmarks_set_center_from_file(this_->bookmarks, center_file); 3041 bookmarks_set_center_from_file(this_->bookmarks, center_file);
3054 g_free(center_file); 3042 g_free(center_file);
3043
3055#if 0 3044#if 0
3056 if (this_->menubar) 3045 if (this_->menubar)
3057 { 3046 {
3058 men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL); 3047 men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL);
3059 if (men) 3048 if (men)
3060 { 3049 {
3061 navit_add_menu_windows_items(this_, men); 3050 navit_add_menu_windows_items(this_, men);
3062 } 3051 }
3063 } 3052 }
3064#endif 3053#endif
3065 global_navit = this_; 3054
3066#if 0 3055#if 0
3067 navit_window_roadbook_new(this_); 3056 navit_window_roadbook_new(this_);
3068 navit_window_items_new(this_); 3057 navit_window_items_new(this_);
3069#endif 3058#endif
3070 3059
3086 //{ 3075 //{
3087 // ////DBG dbg(0,"navit_draw_async_003\n"); 3076 // ////DBG dbg(0,"navit_draw_async_003\n");
3088 // navit_draw_async(this_, 1); 3077 // navit_draw_async(this_, 1);
3089 //} 3078 //}
3090 3079
3091 dbg(0,"init ready=%d\n", this_->ready); 3080 dbg(0, "init ready=%d\n", this_->ready);
3092 3081
3093 // draw??????? 3082 // draw???????
3094 // dbg(0,"init DRAW 11\n"); 3083 // dbg(0,"init DRAW 11\n");
3095 // ready to draw map 3084 // ready to draw map
3096 // navit_draw(this_); 3085 // navit_draw(this_);
3135 3124
3136 } 3125 }
3137 if (this_->ready == 3) 3126 if (this_->ready == 3)
3138 { 3127 {
3139 ////DBG dbg(0,"navit_draw_async_004\n"); 3128 ////DBG dbg(0,"navit_draw_async_004\n");
3129 //dbg(0,"DO__DRAW:navit_draw_async call\n");
3140 navit_draw_async(this_, 0); 3130 navit_draw_async(this_, 0);
3141 } 3131 }
3142} 3132}
3143 3133
3144void navit_zoom_to_route(struct navit *this_, int orientation) 3134void navit_zoom_to_route(struct navit *this_, int orientation)
3353 if (this_->orientation == -1 || keep_orientation) 3343 if (this_->orientation == -1 || keep_orientation)
3354 { 3344 {
3355 p->x = 50 * width / 100; 3345 p->x = 50 * width / 100;
3356 p->y = (50 + offset) * height / 100; 3346 p->y = (50 + offset) * height / 100;
3357 if (dir) 3347 if (dir)
3348 {
3358 *dir = keep_orientation ? this_->orientation : nv->dir; 3349 *dir = keep_orientation ? this_->orientation : nv->dir;
3350 }
3359 } 3351 }
3360 else 3352 else
3361 { 3353 {
3362 int mdir; 3354 int mdir;
3363 if (this_->tracking && this_->tracking_flag) 3355 if (this_->tracking && this_->tracking_flag)
3370 } 3362 }
3371 3363
3372 p->x = (50 - offset * sin(M_PI * mdir / 180.)) * width / 100; 3364 p->x = (50 - offset * sin(M_PI * mdir / 180.)) * width / 100;
3373 p->y = (50 + offset * cos(M_PI * mdir / 180.)) * height / 100; 3365 p->y = (50 + offset * cos(M_PI * mdir / 180.)) * height / 100;
3374 if (dir) 3366 if (dir)
3367 {
3375 *dir = this_->orientation; 3368 *dir = this_->orientation;
3369 }
3376 } 3370 }
3377 return 1; 3371 return 1;
3378} 3372}
3379 3373
3380void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) 3374void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation)
3388 struct navit_vehicle *nv = this_->vehicle; 3382 struct navit_vehicle *nv = this_->vehicle;
3389 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); 3383 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
3390 transform_set_yaw(this_->trans, dir); 3384 transform_set_yaw(this_->trans, dir);
3391 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); 3385 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
3392 if (autozoom) 3386 if (autozoom)
3387 {
3393 navit_autozoom(this_, &nv->coord, nv->speed, 0); 3388 navit_autozoom(this_, &nv->coord, nv->speed, 0);
3389 }
3394} 3390}
3395 3391
3396static void navit_set_center_cursor_draw(struct navit *this_) 3392static void navit_set_center_cursor_draw(struct navit *this_)
3397{ 3393{
3398#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3394#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3401 //dbg(0,"EEnter\n"); 3397 //dbg(0,"EEnter\n");
3402 navit_set_center_cursor(this_, 1, 0); 3398 navit_set_center_cursor(this_, 1, 0);
3403 if (this_->ready == 3) 3399 if (this_->ready == 3)
3404 { 3400 {
3405 //dbg(0,"navit_draw_async_005\n"); 3401 //dbg(0,"navit_draw_async_005\n");
3402 //dbg(0,"DO__DRAW:navit_draw_async call (AS)\n");
3406 navit_draw_async(this_, 1); 3403 navit_draw_async(this_, 1);
3407 } 3404 }
3408} 3405}
3409 3406
3410static void navit_cmd_set_center_cursor(struct navit *this_) 3407static void navit_cmd_set_center_cursor(struct navit *this_)
4054 * Toggle the cursor update : refresh the map each time the cursor has moved (instead of only when it reaches a border) 4051 * Toggle the cursor update : refresh the map each time the cursor has moved (instead of only when it reaches a border)
4055 * 4052 *
4056 * @param navit The navit instance 4053 * @param navit The navit instance
4057 * @returns nothing 4054 * @returns nothing
4058 */ 4055 */
4059
4060static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt) 4056static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt)
4061{ 4057{
4062#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4058#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4063 dbg(0,"+#+:enter\n"); 4059 dbg(0,"+#+:enter\n");
4064#endif 4060#endif
4066 4062
4067 struct point cursor_pnt; 4063 struct point cursor_pnt;
4068 enum projection pro; 4064 enum projection pro;
4069 4065
4070 if (this_->blocked) 4066 if (this_->blocked)
4067 {
4071 return; 4068 return;
4069 }
4070
4072 if (pnt) 4071 if (pnt)
4073 { 4072 {
4074 cursor_pnt = *pnt; 4073 cursor_pnt = *pnt;
4075 } 4074 }
4076 else 4075 else
4077 { 4076 {
4078 pro = transform_get_projection(this_->trans_cursor); 4077 pro = transform_get_projection(this_->trans_cursor);
4079 if (!pro) 4078 if (!pro)
4079 {
4080 return; 4080 return;
4081 }
4081 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 4082 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
4082 } 4083 }
4084
4083 ////DBG dbg(0,"xx=%d\n",cursor_pnt.x); 4085 //dbg(0,"xx=%d\n",cursor_pnt.x);
4084 ////DBG dbg(0,"yy=%d\n",cursor_pnt.y); 4086 //dbg(0,"yy=%d\n",cursor_pnt.y);
4085 4087
4086 global_vehicle_pos_onscreen.x = cursor_pnt.x; 4088 global_vehicle_pos_onscreen.x = cursor_pnt.x;
4087 global_vehicle_pos_onscreen.y = cursor_pnt.y; 4089 global_vehicle_pos_onscreen.y = cursor_pnt.y;
4088 4090
4089 ////DBG dbg(0,"xx=%d\n",pnt->x); 4091 //dbg(0,"xx=%d\n",cursor_pnt.x);
4090 ////DBG dbg(0,"yy=%d\n",pnt->y); 4092 //dbg(0,"yy=%d\n",cursor_pnt.y);
4091 ////DBG dbg(0,"vehicle_draw_001\n"); 4093 //dbg(0,"vehicle_draw_001\n");
4092 vehicle_draw(nv->vehicle, this_->gra, &cursor_pnt, pnt ? 0 : 1, nv->dir - transform_get_yaw(this_->trans_cursor), nv->speed); 4094 vehicle_draw(nv->vehicle, this_->gra, &cursor_pnt, 0, nv->dir - transform_get_yaw(this_->trans_cursor), nv->speed);
4093#if 0 4095#if 0
4094 if (pnt) 4096 if (pnt)
4095 pnt2=*pnt; 4097 pnt2=*pnt;
4096 else 4098 else
4097 { 4099 {
4104 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1); 4106 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1);
4105#endif 4107#endif
4106#endif 4108#endif
4107} 4109}
4108 4110
4111// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4112// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4113// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4109static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) 4114static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
4110{ 4115{
4111#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4116#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4112 dbg(0,"+#+:enter\n"); 4117 dbg(0,"+#+:enter\n");
4113#endif 4118#endif
4117#endif 4122#endif
4118 4123
4119 struct attr attr_valid, attr_dir, attr_speed, attr_pos; 4124 struct attr attr_valid, attr_dir, attr_speed, attr_pos;
4120 struct pcoord cursor_pc; 4125 struct pcoord cursor_pc;
4121 struct point cursor_pnt, *pnt = &cursor_pnt; 4126 struct point cursor_pnt, *pnt = &cursor_pnt;
4127 struct point old_cursor_pnt;
4122 struct tracking *tracking = NULL; 4128 struct tracking *tracking = NULL;
4123 struct pcoord pc[16]; 4129 struct pcoord pc[16];
4124 enum projection pro = transform_get_projection(this_->trans_cursor); 4130 enum projection pro = transform_get_projection(this_->trans_cursor);
4125 int count; 4131 int count;
4132 int old_dir;
4133 int old_pos_invalid;
4126 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *); 4134 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
4127 void *attr_object; 4135 void *attr_object;
4128 char *destination_file; 4136 char *destination_file;
4129 4137
4130 if (this_->ready != 3) 4138 if (this_->ready != 3)
4157 { 4165 {
4158 return; 4166 return;
4159 } 4167 }
4160 } 4168 }
4161 4169
4170 // load attrs with data from vehicle
4162 if (!get_attr(attr_object, attr_position_direction, &attr_dir, NULL) || !get_attr(attr_object, attr_position_speed, &attr_speed, NULL) || !get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL)) 4171 if (!get_attr(attr_object, attr_position_direction, &attr_dir, NULL) || !get_attr(attr_object, attr_position_speed, &attr_speed, NULL) || !get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL))
4163 { 4172 {
4164 return; 4173 return;
4165 } 4174 }
4175 // load attrs with data from vehicle
4176
4177
4178 // save old value
4179 old_dir = nv->dir;
4166 4180
4167 nv->dir = *attr_dir.u.numd; 4181 nv->dir = *attr_dir.u.numd;
4168 nv->speed = *attr_speed.u.numd; 4182 nv->speed = *attr_speed.u.numd;
4183
4184 // old values ---------
4185 if ((global_last_vehicle_pos_geo.lat != 0.0) && (global_last_vehicle_pos_geo.lng != 0.0))
4186 {
4187 transform_from_geo(pro, &global_last_vehicle_pos_geo, &nv->coord);
4188 transform(this_->trans_cursor, pro, &nv->coord, &old_cursor_pnt, 1, 0, 0, NULL);
4189 old_pos_invalid = 0;
4190
4191 // XXX // dbg(0,"old values lat:%f lon:%f px:%d py:%d\n", global_last_vehicle_pos_geo.lat, global_last_vehicle_pos_geo.lng, old_cursor_pnt.x, old_cursor_pnt.y);
4192 }
4193 else
4194 {
4195 old_pos_invalid = 1;
4196 }
4197 // old values ---------
4198
4199
4169 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord); 4200 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
4201
4202 // save this position
4203 global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat;
4204 global_last_vehicle_pos_geo.lng = attr_pos.u.coord_geo->lng;
4205 // save this position
4206
4207
4208 // XXX // dbg(0,"v1 lat:%f lon:%f x:%d y:%d\n",attr_pos.u.coord_geo->lat, attr_pos.u.coord_geo->lng, nv->coord.x, nv->coord.y);
4209
4170 if (nv != this_->vehicle) 4210 //if (nv != this_->vehicle)
4171 { 4211 //{
4172 if (hold_drawing == 0) 4212 // if (hold_drawing == 0)
4173 { 4213 // {
4174 navit_vehicle_draw(this_, nv, NULL); 4214 // navit_vehicle_draw(this_, nv, NULL);
4175 } 4215 // }
4176 return; 4216 // return;
4177 } 4217 //}
4178 cursor_pc.x = nv->coord.x; 4218 cursor_pc.x = nv->coord.x;
4179 cursor_pc.y = nv->coord.y; 4219 cursor_pc.y = nv->coord.y;
4180 cursor_pc.pro = pro; 4220 cursor_pc.pro = pro;
4181 if (this_->route) 4221 if (this_->route)
4182 { 4222 {
4192 4232
4193 callback_list_call_attr_0(this_->attr_cbl, attr_position); 4233 callback_list_call_attr_0(this_->attr_cbl, attr_position);
4194 4234
4195 // navit_textfile_debug_log(this_, "type=trackpoint_tracked"); 4235 // navit_textfile_debug_log(this_, "type=trackpoint_tracked");
4196 /* 4236 /*
4197 if (this_->gui && nv->speed > MYSTERY_SPEED) 4237 if (this_->gui && nv->speed > MYSTERY_SPEED)
4198 { 4238 {
4199 // stupid!!!! this gets called every second!!! fixme!!!!!! 4239 // stupid!!!! this gets called every second!!! fixme!!!!!!
4200 navit_disable_suspend(); 4240 navit_disable_suspend();
4201 // stupid!!!! this gets called every second!!! fixme!!!!!! 4241 // stupid!!!! this gets called every second!!! fixme!!!!!!
4202 } 4242 }
4203 */ 4243 */
4204 4244
4205 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 4245 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
4246 // XXX // dbg(0,"v2 px:%d py:%d x:%d y:%d\n", cursor_pnt.x, cursor_pnt.y, nv->coord.x, nv->coord.y);
4247
4248
4249 if (old_pos_invalid == 0)
4250 {
4251 int delta_x = cursor_pnt.x - old_cursor_pnt.x;
4252 int delta_y = cursor_pnt.y - old_cursor_pnt.y;
4253 int delta_angle = nv->dir - old_dir;
4254
4255#ifdef HAVE_API_ANDROID
4256 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle);
4257 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle);
4258#endif
4259 }
4260
4206 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border))) 4261 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border)))
4207 { 4262 {
4208 if (hold_drawing == 0) 4263 if (hold_drawing == 0)
4209 { 4264 {
4210 //dbg(0,"call:navit_set_center_cursor_draw:start\n"); 4265 //dbg(0,"call:navit_set_center_cursor_draw:start\n");
4289 4344
4290#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4345#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4291 dbg(0,"+#+:leave\n"); 4346 dbg(0,"+#+:leave\n");
4292#endif 4347#endif
4293} 4348}
4349// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4350// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4351// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4352
4294 4353
4295/** 4354/**
4296 * Set the position of the vehicle 4355 * Set the position of the vehicle
4297 * 4356 *
4298 * @param navit The navit instance 4357 * @param navit The navit instance
4299 * @param c The coordinate to set as position 4358 * @param c The coordinate to set as position
4300 * @returns nothing 4359 * @returns nothing
4301 */ 4360 */
4302
4303void navit_set_position(struct navit *this_, struct pcoord *c) 4361void navit_set_position(struct navit *this_, struct pcoord *c)
4304{ 4362{
4305#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4363#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4306 dbg(0,"+#+:enter\n"); 4364 dbg(0,"+#+:enter\n");
4307#endif 4365#endif
4398 struct attr follow, active, animate; 4456 struct attr follow, active, animate;
4399 nv->vehicle = v; 4457 nv->vehicle = v;
4400 nv->follow = 0; 4458 nv->follow = 0;
4401 nv->last.x = 0; 4459 nv->last.x = 0;
4402 nv->last.y = 0; 4460 nv->last.y = 0;
4461
4462 global_last_vehicle_pos_geo.lat = 0;
4463 global_last_vehicle_pos_geo.lng = 0;
4464
4403 nv->animate_cursor = 0; 4465 nv->animate_cursor = 0;
4404 if ((vehicle_get_attr(v, attr_follow, &follow, NULL))) 4466 if ((vehicle_get_attr(v, attr_follow, &follow, NULL)))
4405 nv->follow = follow.u.num; 4467 nv->follow = follow.u.num;
4406 nv->follow_curr = nv->follow; 4468 nv->follow_curr = nv->follow;
4407 this_->vehicles = g_list_append(this_->vehicles, nv); 4469 this_->vehicles = g_list_append(this_->vehicles, nv);
4411 nv->animate_cursor = animate.u.num; 4473 nv->animate_cursor = animate.u.num;
4412 nv->callback.type = attr_callback; 4474 nv->callback.type = attr_callback;
4413 4475
4414 // gets called via this callback in vehicle_android.c [in function: vehicle_android_callback] 4476 // gets called via this callback in vehicle_android.c [in function: vehicle_android_callback]
4415 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv); 4477 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv);
4478 callback_add_names(nv->callback.u.callback, "navit_add_vehicle", "navit_vehicle_update");
4416 4479
4417 //dbg(0,"EEnter 11\n"); 4480 //dbg(0,"EEnter 11\n");
4418 vehicle_add_attr(nv->vehicle, &nv->callback); 4481 vehicle_add_attr(nv->vehicle, &nv->callback);
4419 //dbg(0,"EEnter 22\n"); 4482 //dbg(0,"EEnter 22\n");
4420 vehicle_set_attr(nv->vehicle, &this_->self); 4483 vehicle_set_attr(nv->vehicle, &this_->self);
4648 ////DBG dbg(0,"EEnter\n"); 4711 ////DBG dbg(0,"EEnter\n");
4649 4712
4650 gui_disable_suspend(global_navit->gui); 4713 gui_disable_suspend(global_navit->gui);
4651 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend); 4714 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend);
4652} 4715}
4653
4654 4716
4655/** 4717/**
4656 * @brief Dumps item attrs to string 4718 * @brief Dumps item attrs to string
4657 * 4719 *
4658 * @param item item 4720 * @param item item
4754 // g_free(item); 4816 // g_free(item);
4755 4817
4756 return ret_value; 4818 return ret_value;
4757} 4819}
4758 4820
4759
4760int navit_normal_item(enum item_type type) 4821int navit_normal_item(enum item_type type)
4761{ 4822{
4762 if ((type > type_none)&&(type < type_waypoint)) 4823 if ((type > type_none) && (type < type_waypoint))
4763 { 4824 {
4764 return 1; 4825 return 1;
4765 } 4826 }
4766 else if ((type >= type_poi_land_feature)&&(type <= type_poi_zoo)) 4827 else if ((type >= type_poi_land_feature) && (type <= type_poi_zoo))
4767 { 4828 {
4768 return 1; 4829 return 1;
4769 } 4830 }
4770 else if ((type >= type_traffic_signals)&&(type <= type_poi_cafe)) 4831 else if ((type >= type_traffic_signals) && (type <= type_poi_cafe))
4771 { 4832 {
4772 return 1; 4833 return 1;
4773 } 4834 }
4774 else if ((type >= type_poi_peak)&&(type <= type_poi_ruins)) 4835 else if ((type >= type_poi_peak) && (type <= type_poi_ruins))
4775 { 4836 {
4776 return 1; 4837 return 1;
4777 } 4838 }
4778 else if ((type >= type_poi_post_box)&&(type <= type_house_number)) 4839 else if ((type >= type_poi_post_box) && (type <= type_house_number))
4779 { 4840 {
4780 return 1; 4841 return 1;
4781 } 4842 }
4782 else if ((type >= type_poi_playground)&&(type <= type_poi_shop_photo)) 4843 else if ((type >= type_poi_playground) && (type <= type_poi_shop_photo))
4783 { 4844 {
4784 return 1; 4845 return 1;
4785 } 4846 }
4786 else if (type == type_place_label) 4847 else if (type == type_place_label)
4787 { 4848 {
4788 return 1; 4849 return 1;
4789 } 4850 }
4790 else if ((type >= type_line)&&(type <= type_ferry)) 4851 else if ((type >= type_line) && (type <= type_ferry))
4791 { 4852 {
4792 return 1; 4853 return 1;
4793 } 4854 }
4794 else if (type == type_street_unkn) 4855 else if (type == type_street_unkn)
4795 { 4856 {
4796 return 1; 4857 return 1;
4797 } 4858 }
4798 else if ((type >= type_aeroway_runway)&&(type <= type_footway_and_piste_nordic)) 4859 else if ((type >= type_aeroway_runway) && (type <= type_footway_and_piste_nordic))
4799 { 4860 {
4800 return 1; 4861 return 1;
4801 } 4862 }
4802 else if ((type >= type_house_number_interpolation_even)&&(type <= type_city_wall)) 4863 else if ((type >= type_house_number_interpolation_even) && (type <= type_city_wall))
4803 { 4864 {
4804 return 1; 4865 return 1;
4805 } 4866 }
4806 else if ((type >= type_border_city)&&(type <= type_border_county)) 4867 else if ((type >= type_border_city) && (type <= type_border_county))
4807 { 4868 {
4808 return 1; 4869 return 1;
4809 } 4870 }
4810 else if ((type >= type_forest_way_1)&&(type <= type_forest_way_4)) 4871 else if ((type >= type_forest_way_1) && (type <= type_forest_way_4))
4811 { 4872 {
4812 return 1; 4873 return 1;
4813 } 4874 }
4814 else if ((type >= type_area)&&(type <= type_poly_museum)) 4875 else if ((type >= type_area) && (type <= type_poly_museum))
4815 { 4876 {
4816 return 1; 4877 return 1;
4817 } 4878 }
4818 else if ((type >= type_poly_commercial_center)&&(type <= type_tundra)) 4879 else if ((type >= type_poly_commercial_center) && (type <= type_tundra))
4819 { 4880 {
4820 return 1; 4881 return 1;
4821 } 4882 }
4822 else if ((type >= type_poly_building)&&(type <= type_poly_terminal)) 4883 else if ((type >= type_poly_building) && (type <= type_poly_terminal))
4823 { 4884 {
4824 return 1; 4885 return 1;
4825 } 4886 }
4826 else if ((type >= type_poly_sports_centre)&&(type <= type_poly_aeroway_runway)) 4887 else if ((type >= type_poly_sports_centre) && (type <= type_poly_aeroway_runway))
4827 { 4888 {
4828 return 1; 4889 return 1;
4829 } 4890 }
4830 4891
4831 return 0; 4892 return 0;
4908 mindist = dist; 4969 mindist = dist;
4909 if (ret_str != NULL) 4970 if (ret_str != NULL)
4910 { 4971 {
4911 g_free(ret_str); 4972 g_free(ret_str);
4912 } 4973 }
4913 ret_str=navit_item_dump(item, pretty); 4974 ret_str = navit_item_dump(item, pretty);
4914 } 4975 }
4915 } 4976 }
4916 else 4977 else
4917 { 4978 {
4918 dist = transform_distance_sq(&c, &c2); 4979 dist = transform_distance_sq(&c, &c2);
4921 mindist = dist; 4982 mindist = dist;
4922 if (ret_str != NULL) 4983 if (ret_str != NULL)
4923 { 4984 {
4924 g_free(ret_str); 4985 g_free(ret_str);
4925 } 4986 }
4926 ret_str=navit_item_dump(item, pretty); 4987 ret_str = navit_item_dump(item, pretty);
4927 } 4988 }
4928 } 4989 }
4929 // dbg(0,"*end\n"); 4990 // dbg(0,"*end\n");
4930 } 4991 }
4931 } 4992 }
4943 ret_str = g_strdup_printf(""); 5004 ret_str = g_strdup_printf("");
4944 } 5005 }
4945 5006
4946 return ret_str; 5007 return ret_str;
4947} 5008}
4948
4949
4950
4951
4952 5009
4953/** 5010/**
4954 * @brief Finds the nearest street to a given coordinate 5011 * @brief Finds the nearest street to a given coordinate
4955 * 5012 *
4956 * @param ms The mapset to search in for the street 5013 * @param ms The mapset to search in for the street
5086 // set global value :-( 5143 // set global value :-(
5087 dist_to_street = mindist; 5144 dist_to_street = mindist;
5088 return street_name; 5145 return street_name;
5089} 5146}
5090 5147
5091
5092
5093/** 5148/**
5094 * @brief Finds the nearest street or housenumber to a given coordinate 5149 * @brief Finds the nearest street or housenumber to a given coordinate
5095 * 5150 *
5096 * @param ms The mapset to search in for the street 5151 * @param ms The mapset to search in for the street
5097 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ] 5152 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ]
5126 // street_name = g_strdup_printf(" "); 5181 // street_name = g_strdup_printf(" ");
5127 street_name = g_strdup(street_name_saved); 5182 street_name = g_strdup(street_name_saved);
5128 // first find a street 5183 // first find a street
5129 5184
5130 mindist = dist_to_street; // start with small radius at the beginning! (only use housenumber of different street, if we are really close to it!!) 5185 mindist = dist_to_street; // start with small radius at the beginning! (only use housenumber of different street, if we are really close to it!!)
5131 // global value -> this is naughty :-) 5186 // global value -> this is naughty :-)
5132 5187
5133 if (mindist < 8) 5188 if (mindist < 8)
5134 { 5189 {
5135 // so we can find other housenumbers if we are very close 5190 // so we can find other housenumbers if we are very close
5136 mindist = 8; 5191 mindist = 8;
5236 } 5291 }
5237 } 5292 }
5238 } 5293 }
5239 } 5294 }
5240 5295
5241
5242#if 0 5296#if 0
5243 //else if (item->type > type_line) 5297 //else if (item->type > type_line)
5244 if (1 == 0) // DISABLED !!!!!! 5298 if (1 == 0) // DISABLED !!!!!!
5299
5245 { 5300 {
5246 if (item_get_default_flags(item->type)) 5301 if (item_get_default_flags(item->type))
5247 { 5302 {
5248 sd = street_get_data(item); 5303 sd = street_get_data(item);
5249 if (!sd) 5304 if (!sd)
5321 5376
5322 mapset_close(h); 5377 mapset_close(h);
5323 return street_name; 5378 return street_name;
5324} 5379}
5325 5380
5326
5327/** 5381/**
5328 * @brief Finds the nearest street to a given coordinate 5382 * @brief Finds the nearest street to a given coordinate
5329 * 5383 *
5330 * @param ms The mapset to search in for the street 5384 * @param ms The mapset to search in for the street
5331 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ] 5385 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ]
5406 if (dist < mindist) 5460 if (dist < mindist)
5407 { 5461 {
5408 mindist = dist; 5462 mindist = dist;
5409 5463
5410 /* 5464 /*
5411 if (item_attr_get(item, attr_label, &street_name_attr)) 5465 if (item_attr_get(item, attr_label, &street_name_attr))
5412 { 5466 {
5413 found_good = 1; 5467 found_good = 1;
5414 } 5468 }
5415 else if (item_attr_get(item, attr_street_name, &street_name_attr)) 5469 else if (item_attr_get(item, attr_street_name, &street_name_attr))
5416 { 5470 {
5417 found_good = 1; 5471 found_good = 1;
5418 } 5472 }
5419 else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr)) 5473 else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr))
5420 { 5474 {
5421 found_good = 1; 5475 found_good = 1;
5422 } 5476 }
5423 */ 5477 */
5424 5478
5425 // allow any street/line, so you can select streets without name also! 5479 // allow any street/line, so you can select streets without name also!
5426 found_good = 1; 5480 found_good = 1;
5427 } 5481 }
5428 5482
5453 // dbg(0,"sd_copy->count=%d\n", sd_copy->count); 5507 // dbg(0,"sd_copy->count=%d\n", sd_copy->count);
5454 5508
5455 for (i = 0; i < sd_copy->count; i++) 5509 for (i = 0; i < sd_copy->count; i++)
5456 { 5510 {
5457 /* 5511 /*
5458 unsigned int x; 5512 unsigned int x;
5459 unsigned int y; 5513 unsigned int y;
5460 char *sign_x = ""; 5514 char *sign_x = "";
5461 char *sign_y = ""; 5515 char *sign_y = "";
5462 5516
5463 if ( c->x < 0 ) { 5517 if ( c->x < 0 ) {
5464 x = -c->x; 5518 x = -c->x;
5465 sign_x = "-"; 5519 sign_x = "-";
5466 } else { 5520 } else {
5467 x = c->x; 5521 x = c->x;
5468 } 5522 }
5469 if ( c->y < 0 ) { 5523 if ( c->y < 0 ) {
5470 y = -c->y; 5524 y = -c->y;
5471 sign_y = "-"; 5525 sign_y = "-";
5472 } else { 5526 } else {
5473 y = c->y; 5527 y = c->y;
5474 } 5528 }
5475 */ 5529 */
5476 5530
5477 street_coords_tmp = street_coords; 5531 street_coords_tmp = street_coords;
5478 if (street_coords == NULL) 5532 if (street_coords == NULL)
5479 { 5533 {
5480 street_coords = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y); 5534 street_coords = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y);
5492 } 5546 }
5493 5547
5494 return street_coords; 5548 return street_coords;
5495} 5549}
5496 5550
5497 5551// UNUSDED -------
5552// UNUSDED -------
5498int navit_block(struct navit *this_, int block) 5553int navit_block(struct navit *this_, int block)
5499{ 5554{
5500#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5555#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5501 dbg(0,"+#+:enter\n"); 5556 dbg(0,"+#+:enter\n");
5502#endif 5557#endif
5536 { 5591 {
5537 vehicle_destroy(this_->vehicle->vehicle); 5592 vehicle_destroy(this_->vehicle->vehicle);
5538 } 5593 }
5539 5594
5540 /* 5595 /*
5541 if (this_->bookmarks) 5596 if (this_->bookmarks)
5542 { 5597 {
5543 dbg(0, "save position to file\n"); 5598 dbg(0, "save position to file\n");
5544 char *center_file = bookmarks_get_center_file(TRUE); 5599 char *center_file = bookmarks_get_center_file(TRUE);
5545 bookmarks_write_center_to_file(this_->bookmarks, center_file); 5600 bookmarks_write_center_to_file(this_->bookmarks, center_file);
5546 g_free(center_file); 5601 g_free(center_file);
5547 bookmarks_destroy(this_->bookmarks); 5602 bookmarks_destroy(this_->bookmarks);
5548 dbg(0, "save position to file -> ready\n"); 5603 dbg(0, "save position to file -> ready\n");
5549 } 5604 }
5550 */ 5605 */
5551 5606
5552 dbg(0, "ex 001\n"); 5607 dbg(0, "ex 001\n");
5553 callback_destroy(this_->nav_speech_cb); 5608 callback_destroy(this_->nav_speech_cb);
5554 dbg(0, "ex 002\n"); 5609 dbg(0, "ex 002\n");
5555 callback_destroy(this_->roadbook_callback); 5610 callback_destroy(this_->roadbook_callback);
5559 callback_destroy(this_->motion_timeout_callback); 5614 callback_destroy(this_->motion_timeout_callback);
5560 dbg(0, "ex 005\n"); 5615 dbg(0, "ex 005\n");
5561 callback_destroy(this_->progress_cb); 5616 callback_destroy(this_->progress_cb);
5562 dbg(0, "ex 006\n"); 5617 dbg(0, "ex 006\n");
5563 /* 5618 /*
5564 if (this_->gra) 5619 if (this_->gra)
5565 graphics_remove_callback(this_->gra, this_->resize_callback); 5620 graphics_remove_callback(this_->gra, this_->resize_callback);
5566 callback_destroy(this_->resize_callback); 5621 callback_destroy(this_->resize_callback);
5567 */ 5622 */
5568 dbg(0, "ex 007\n"); 5623 dbg(0, "ex 007\n");
5569 /* 5624 /*
5570 if (this_->gra) 5625 if (this_->gra)
5571 graphics_remove_callback(this_->gra, this_->button_callback); 5626 graphics_remove_callback(this_->gra, this_->button_callback);
5572 callback_destroy(this_->button_callback); 5627 callback_destroy(this_->button_callback);
5573 */ 5628 */
5574 dbg(0, "ex 008\n"); 5629 dbg(0, "ex 008\n");
5575 /* 5630 /*
5576 if (this_->gra) 5631 if (this_->gra)
5577 graphics_remove_callback(this_->gra, this_->motion_callback); 5632 graphics_remove_callback(this_->gra, this_->motion_callback);
5578 callback_destroy(this_->motion_callback); 5633 callback_destroy(this_->motion_callback);
5579 */ 5634 */
5580 dbg(0, "ex 009\n"); 5635 dbg(0, "ex 009\n");
5581 if (this_->gra) 5636 if (this_->gra)
5582 { 5637 {
5583 graphics_remove_callback(this_->gra, this_->predraw_callback); 5638 graphics_remove_callback(this_->gra, this_->predraw_callback);
5584 } 5639 }

Legend:
Removed from v.29  
changed lines
  Added in v.30

   
Visit the ZANavi Wiki