/[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 39 Revision 40
1/** 1/**
2 * ZANavi, Zoff Android Navigation system. 2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2013 Zoff <zoff@zoff.cc> 3 * Copyright (C) 2011-2014 Zoff <zoff@zoff.cc>
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
92#endif 92#endif
93#ifdef HAVE_API_WIN32_CE 93#ifdef HAVE_API_WIN32_CE
94#include "libc.h" 94#include "libc.h"
95#endif 95#endif
96 96
97
98
99
100
101
102
103
104
105
106
107
108
109// #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
110
111
112// --------------- debug function calls ------------------
113// --------------- debug function calls ------------------
114#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
115 #undef return2
116 #define return2 dbg_func(0, global_func_indent_counter, "return(%d)\n", __LINE__);global_func_indent_counter--;return
117
118 #define __F_START__ global_func_indent_counter++;dbg_func(0, global_func_indent_counter, "enter\n");
119 #define __F_END__ dbg_func(0, global_func_indent_counter, "leave\n");global_func_indent_counter--;
120#else
121 #undef return2
122 #define return2 return
123
124 #define __F_START__
125 #define __F_END__
126#endif
127// --------------- debug function calls ------------------
128// --------------- debug function calls ------------------
129
130
131
132
133
134
97/** 135/**
98 * @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object 136 * @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object
99 * @{ 137 * @{
100 */ 138 */
101 139
134int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now 172int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now
135int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB) 173int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB)
136int draw_polylines_fast = 0; // default: 0 174int draw_polylines_fast = 0; // default: 0
137int limit_order_corrected = 4; // remain at this order level for drawing streets etc. 175int limit_order_corrected = 4; // remain at this order level for drawing streets etc.
138int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!) 176int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!)
139int global_search_street_size_factor = 1; // make search radius for streets bigger 177int global_search_street_size_factor = 1; // make search radius for streets bigger (not used on indexsearch)
140int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources) 178int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources)
141int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing 179int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing
142int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still 180int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still
143int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles 181int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles
144int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light 182int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light
183int global_clinedrawing_active = 0; // 0 -> java line drawing, 1 -> C line drawing
145int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them 184int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them
146int global_have_dpi_value = 240; 185int global_have_dpi_value = 240;
147float global_dpi_factor = 1.0f; 186float global_dpi_factor = 1.0f;
148int global_order_level_for_fast_draw = 13; 187int global_order_level_for_fast_draw = 13;
149int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map 188int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map
150 // 1 -> show "normal, english" 189 // 1 -> show "normal, english"
151 // 2 -> show only "english" labels 190 // 2 -> show only "english" labels
191int global_avoid_sharp_turns_flag = 0; // 0 -> normal routing, 1 -> try to avoid sharp turns / u-turns
192int global_avoid_sharp_turns_min_angle = 40; // at what angle is it a sharp turn?
193int global_avoid_sharp_turns_min_penalty = 2000; // routing penalty for sharp turns
194
195int global_search_radius_for_housenumbers = 300; // search this far around street-coord to find potential housenumbers for this street
196int global_vehicle_profile = 0; // 0 -> car, 1 -> bicycle, 2 -> bicylce no one-ways
197int global_cycle_lanes_prio = 5; // how much prio weight will be subtracted from prio weight if a road has a cycle lane (painted white line for bicycles)
198int global_cycle_track_prio = 1; // unused for now!!
199
200double global_v_pos_lat = 0.0; // global vehicle position
201double global_v_pos_lng = 0.0; // global vehicle position
202double global_v_pos_dir = 0.0; // global vehicle direction
203
204int global_demo_vehicle = 0;
205int global_demo_vehicle_short_switch = 0;
206long global_last_spoken = -1;
207long global_last_spoken_base = 0;
208
209GList *global_all_cbs = NULL;
210
211struct coord global_debug_route_seg_winner_start;
212struct coord global_debug_route_seg_winner_end;
213struct coord global_debug_seg_winner_start;
214struct coord global_debug_seg_winner_end;
215struct coord global_debug_route_seg_winner_p_start;
216struct coord global_debug_route_seg_winner_p_end;
217struct coord global_debug_seg_winner_p_start;
218struct coord global_debug_seg_route_start;
219struct coord global_debug_seg_route_end;
220struct coord global_debug_trlast_start;
221struct coord global_debug_trlast_end;
222
223struct coord *global_debug_coord_list;
224int global_debug_coord_list_items = 0;
225int global_has_gpsfix = 0;
226int global_pos_is_underground = 0;
227
228
229int global_sharp_turn_list_count = 0;
230struct global_sharp_turn *global_sharp_turn_list = NULL;
231
232int global_freetext_list_count = 0;
233struct global_freetext *global_freetext_list = NULL;
234
152 235
153GHashTable *global_transform_hash = NULL; 236GHashTable *global_transform_hash = NULL;
154GHashTable *global_transform_hash2 = NULL; 237GHashTable *global_transform_hash2 = NULL;
155 238
156long long draw_lines_count_2 = 0; 239long long draw_lines_count_2 = 0;
170int global_old_vehicle_speed = -1; 253int global_old_vehicle_speed = -1;
171int global_old_vehicle_speed_for_autozoom = -1; 254int global_old_vehicle_speed_for_autozoom = -1;
172 255
173void navit_add_mapset(struct navit *this_, struct mapset *ms) 256void navit_add_mapset(struct navit *this_, struct mapset *ms)
174{ 257{
175#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
176 dbg(0,"+#+:enter\n");
177#endif
178 ////DBG dbg(0,"EEnter\n");
179 this_->mapsets = g_list_append(this_->mapsets, ms); 258 this_->mapsets = g_list_append(this_->mapsets, ms);
180#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
181 dbg(0,"+#+:leave\n");
182#endif
183} 259}
184 260
185struct mapset * 261struct mapset *
186navit_get_mapset(struct navit *this_) 262navit_get_mapset(struct navit *this_)
187{ 263{
188#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
189 dbg(0,"+#+:enter\n");
190#endif
191 ////DBG dbg(0,"EEnter\n");
192 if (this_->mapsets) 264 if (this_->mapsets)
193 { 265 {
194 return this_->mapsets->data; 266 return this_->mapsets->data;
195 } 267 }
196 else 268 else
201} 273}
202 274
203struct tracking * 275struct tracking *
204navit_get_tracking(struct navit *this_) 276navit_get_tracking(struct navit *this_)
205{ 277{
206#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
207 dbg(0,"+#+:enter\n");
208#endif
209 ////DBG dbg(0,"EEnter\n");
210 return this_->tracking; 278 return this_->tracking;
211} 279}
212 280
213/** 281/**
214 * @brief Get the user data directory. 282 * @brief Get the user data directory.
221 * 289 *
222 */ 290 */
223char* 291char*
224navit_get_user_data_directory(int create) 292navit_get_user_data_directory(int create)
225{ 293{
226#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
227 dbg(0,"+#+:enter\n");
228#endif
229 ////DBG dbg(0,"EEnter\n");
230 char *dir; 294 char *dir;
231 // dir = getenv("NAVIT_USER_DATADIR"); 295 // dir = getenv("NAVIT_USER_DATADIR");
232 dir = navit_share_dir; 296 dir = navit_share_dir;
233 if (create && !file_exists(dir)) 297 if (create && !file_exists(dir))
234 { 298 {
242 return dir; 306 return dir;
243} /* end: navit_get_user_data_directory(gboolean create) */ 307} /* end: navit_get_user_data_directory(gboolean create) */
244 308
245void navit_draw_async(struct navit *this_, int async) 309void navit_draw_async(struct navit *this_, int async)
246{ 310{
247#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 311__F_START__
248 dbg(0,"+#+:enter\n");
249#endif
250
251 //dbg(0,"DO__DRAW:ndasync enter, async=%d\n", async);
252 312
253 //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked); 313 //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked);
254 if (this_->blocked) 314 if (this_->blocked)
255 { 315 {
256 this_->blocked |= 2; 316 this_->blocked |= 2;
257 //dbg(0,"set this_->blocked=%d\n",this_->blocked); 317 //dbg(0,"set this_->blocked=%d\n",this_->blocked);
258 // dbg(0,"DO__DRAW:ndasync return 001\n"); 318 // dbg(0,"DO__DRAW:ndasync return 001\n");
259 return; 319 return2;
260 } 320 }
321
261 transform_setup_source_rect(this_->trans); 322 transform_setup_source_rect(this_->trans);
262 //dbg(0,"call graphics_draw\n"); 323 //dbg(0,"call graphics_draw\n");
263 324
264 // dbg(0,"DO__DRAW:gras_draw call\n"); 325 // dbg(0,"DO__DRAW:gras_draw call\n");
265 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1); 326 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1);
266 // dbg(0,"DO__DRAW:ndasync leave\n"); 327 // dbg(0,"DO__DRAW:ndasync leave\n");
328
329__F_END__
267} 330}
268 331
269void navit_draw(struct navit *this_) 332void navit_draw(struct navit *this_)
270{ 333{
271#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 334__F_START__
272 dbg(0,"+#+:enter\n");
273#endif
274
275 // dbg(0,"DO__DRAW:nd:enter\n");
276 335
277 //dbg(0,"EEnter this_->ready=%d\n",this_->ready); 336 //dbg(0,"EEnter this_->ready=%d\n",this_->ready);
278 if (this_->ready == 3) 337 if (this_->ready == 3)
279 { 338 {
280 //dbg(0,"navit_draw_async_001\n"); 339 // dbg(0,"navit_draw_async_001\n");
281 // dbg(0,"DO__DRAW:navit_draw_async call\n"); 340 // dbg(0,"DO__DRAW:navit_draw_async call\n");
282 navit_draw_async(this_, 0); 341 navit_draw_async(this_, 0);
283 } 342 }
284 343
285 // dbg(0,"DO__DRAW:nd:leave\n"); 344__F_END__
286} 345}
287 346
288int navit_get_ready(struct navit *this_) 347int navit_get_ready(struct navit *this_)
289{ 348{
290#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
291 dbg(0,"+#+:enter\n");
292#endif
293 ////DBG dbg(0,"EEnter\n");
294 return this_->ready; 349 return this_->ready;
295} 350}
296 351
297// UNUSED ----- 352// UNUSED -----
298// UNUSED ----- 353// UNUSED -----
299void navit_draw_displaylist(struct navit *this_) 354void navit_draw_displaylist(struct navit *this_)
300{ 355{
301#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
302 dbg(0,"+#+:enter\n");
303#endif
304 ////DBG dbg(0,"EEnter\n");
305 if (this_->ready == 3) 356 if (this_->ready == 3)
306 { 357 {
307 // //DBG dbg(0,"call graphics_displaylist_draw 2") 358 // //DBG dbg(0,"call graphics_displaylist_draw 2")
308 graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1); 359 graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1);
309 } 360 }
310} 361}
311 362
312static void navit_map_progress(struct navit *this_) 363static void navit_map_progress(struct navit *this_)
313{ 364{
314#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
315 dbg(0,"+#+:enter\n");
316#endif
317 ////DBG dbg(0,"EEnter\n");
318 struct map *map; 365 struct map *map;
319 struct mapset *ms; 366 struct mapset *ms;
320 struct mapset_handle *msh; 367 struct mapset_handle *msh;
321 struct attr attr; 368 struct attr attr;
322 struct point p; 369 struct point p;
342 mapset_close(msh); 389 mapset_close(msh);
343} 390}
344 391
345static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr) 392static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr)
346{ 393{
347#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 394__F_START__
348 dbg(0,"+#+:enter\n");
349#endif
350 395
351 //dbg(0,"enter\n");
352 int updated; 396 int updated;
353 397
354 if ((this_->route) && (this_->route->route_status_was_updated == 1)) 398 if ((this_->route) && (this_->route->route_status_was_updated == 1))
355 { 399 {
356 this_->route->route_status_was_updated = 0; 400 this_->route->route_status_was_updated = 0;
360#endif 404#endif
361 } 405 }
362 406
363 if (attr->type != attr_route_status) 407 if (attr->type != attr_route_status)
364 { 408 {
365 ////DBG dbg(0,"ret 1\n");
366 return; 409 return2;
367 } 410 }
411
368 updated = attr->u.num; 412 updated = attr->u.num;
369 ////DBG dbg(0,"updated=%d\n", updated); 413
370 if (this_->ready != 3) 414 if (this_->ready != 3)
371 { 415 {
372 ////DBG dbg(0,"ret 2\n");
373 return; 416 return2;
374 } 417 }
418
375 if (updated != route_status_path_done_new) 419 if (updated != route_status_path_done_new)
376 { 420 {
377 ////DBG dbg(0,"ret 3\n");
378 return; 421 return2;
379 } 422 }
423
380 if (this_->vehicle) 424 if (this_->vehicle)
381 { 425 {
382 if (this_->vehicle->follow_curr == 1) 426 if (this_->vehicle->follow_curr == 1)
383 { 427 {
384 ////DBG dbg(0,"ret 4\n");
385 ////DBG dbg(0,"disabled -> we want redraw!!\n"); 428 ////DBG dbg(0,"disabled -> we want redraw!!\n");
386 // return; 429 // return2;
387 } 430 }
431
388 if (this_->vehicle->follow_curr <= this_->vehicle->follow) 432 if (this_->vehicle->follow_curr <= this_->vehicle->follow)
389 { 433 {
390 this_->vehicle->follow_curr = this_->vehicle->follow; 434 this_->vehicle->follow_curr = this_->vehicle->follow;
391 } 435 }
392 } 436 }
393 ////DBG dbg(0,"draw s*\n"); 437
394 navit_draw(this_); 438 // *++*-- DISABLED --*++* // navit_draw(this_);
395 ////DBG dbg(0,"draw e*\n"); 439
440__F_END__
396} 441}
397 442
398void navit_handle_resize(struct navit *this_, int w, int h) 443void navit_handle_resize(struct navit *this_, int w, int h)
399{ 444{
400#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 445__F_START__
401 dbg(0,"+#+:enter\n");
402#endif
403 446
404 // dbg(0, "EEnter %p\n", this_);
405 struct map_selection sel; 447 struct map_selection sel;
448
406 int callback = (this_->ready == 1); 449 int callback = (this_->ready == 1);
407 // dbg(0, "pre this_->ready=%d\n", this_->ready);
408 this_->ready = this_->ready | 2; 450 this_->ready = this_->ready | 2;
409 // dbg(0, "set this_->ready=%d\n", this_->ready); 451
410 memset(&sel, 0, sizeof(sel)); 452 memset(&sel, 0, sizeof(sel));
453
411 this_->w = w; 454 this_->w = w;
412 this_->h = h; 455 this_->h = h;
413 sel.u.p_rect.rl.x = w; 456 sel.u.p_rect.rl.x = w;
414 sel.u.p_rect.rl.y = h; 457 sel.u.p_rect.rl.y = h;
415 transform_set_screen_selection(this_->trans, &sel); 458 transform_set_screen_selection(this_->trans, &sel);
416 graphics_init(this_->gra); 459 graphics_init(this_->gra);
417 graphics_set_rect(this_->gra, &sel.u.p_rect); 460 graphics_set_rect(this_->gra, &sel.u.p_rect);
461
418 if (callback) 462 if (callback)
419 { 463 {
420 //DBG dbg(0,"callback do\n"); 464 // HINT: this triggers all the OSD drawing (next turn, ETA, etc.)
421 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); 465 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
422 } 466 }
467
423 if (this_->ready == 3) 468 if (this_->ready == 3)
424 { 469 {
425 // dbg(0, "navit_draw_async_002\n"); 470 // dbg(0,"navit_draw_async_007\n");
426 // navit_draw_async(this_, 1);
427 // dbg(0,"DO__DRAW:navit_draw_async call\n");
428 navit_draw_async(this_, 0); 471 navit_draw_async(this_, 0);
429 } 472 }
430 473
431 // dbg(0, "return\n"); 474__F_END__
432} 475}
433 476
434void navit_resize(void *data, int w, int h) 477void navit_resize(void *data, int w, int h)
435{ 478{
436#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
437 dbg(0,"+#+:enter\n");
438#endif
439
440 //DBG dbg(0,"EEnter %p\n", data);
441 struct navit *this = data; 479 struct navit *this = data;
442 if (!this->ignore_graphics_events) 480 if (!this->ignore_graphics_events)
443 { 481 {
444 //DBG dbg(0,"11\n"); 482 //DBG dbg(0,"11\n");
445 navit_handle_resize(this, w, h); 483 navit_handle_resize(this, w, h);
446 } 484 }
447} 485}
448 486
449int navit_get_width(struct navit *this_) 487int navit_get_width(struct navit *this_)
450{ 488{
451#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
452 dbg(0,"+#+:enter\n");
453#endif
454 ////DBG dbg(0,"EEnter\n");
455 return this_->w; 489 return this_->w;
456} 490}
457 491
458int navit_get_height(struct navit *this_) 492int navit_get_height(struct navit *this_)
459{ 493{
460#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
461 dbg(0,"+#+:enter\n");
462#endif
463 ////DBG dbg(0,"EEnter\n");
464 return this_->h; 494 return this_->h;
465} 495}
466 496
467static void navit_popup(void *data) 497static void navit_popup(void *data)
468{ 498{
469#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
470 dbg(0,"+#+:enter\n");
471#endif
472 ////DBG dbg(0,"EEnter\n");
473 struct navit *this_ = data; 499 struct navit *this_ = data;
474 popup(this_, 1, &this_->pressed); 500 popup(this_, 1, &this_->pressed);
475 this_->button_timeout = NULL; 501 this_->button_timeout = NULL;
476 this_->popped = 1; 502 this_->popped = 1;
477} 503}
478 504
479int navit_ignore_button(struct navit *this_) 505int navit_ignore_button(struct navit *this_)
480{ 506{
481#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
482 dbg(0,"+#+:enter\n");
483#endif
484 ////DBG dbg(0,"EEnter\n");
485 if (this_->ignore_button) 507 if (this_->ignore_button)
486 return 1; 508 return 1;
509
487 this_->ignore_button = 1; 510 this_->ignore_button = 1;
488 return 0; 511 return 0;
489} 512}
490 513
491void navit_ignore_graphics_events(struct navit *this_, int ignore) 514void navit_ignore_graphics_events(struct navit *this_, int ignore)
492{ 515{
493#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
494 dbg(0,"+#+:enter\n");
495#endif
496 ////DBG dbg(0,"EEnter\n");
497 this_->ignore_graphics_events = ignore; 516 this_->ignore_graphics_events = ignore;
498} 517}
499 518
500void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot) 519void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot)
501{ 520{
502#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
503 dbg(0,"+#+:enter\n");
504#endif
505 ////DBG dbg(0,"EEnter\n");
506 struct coord co, cn; 521 struct coord co, cn;
507 struct coord c, *cp; 522 struct coord c, *cp;
508 int yaw; 523 int yaw;
509 double angleo, anglen; 524 double angleo, anglen;
510 525
526 transform_set_center(tr, &c); 541 transform_set_center(tr, &c);
527} 542}
528 543
529void navit_set_timeout(struct navit *this_) 544void navit_set_timeout(struct navit *this_)
530{ 545{
531#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
532 dbg(0,"+#+:enter\n");
533#endif
534
535 // --------- DISABLE ----------- 546 // --------- DISABLE -----------
536 return; 547 return;
537 // --------- DISABLE ----------- 548 // --------- DISABLE -----------
538} 549}
539 550
540int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback) 551int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
541{ 552{
542#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
543 dbg(0,"+#+:enter\n");
544#endif
545 ////DBG dbg(0,"EEnter\n");
546 int border = 16; 553 int border = 16;
547 554
548 // dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button); 555 // dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button);
549 callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p); 556 callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p);
550 if (this_->ignore_button) 557 if (this_->ignore_button)
613#endif 620#endif
614 graphics_draw_drag(this_->gra, NULL); 621 graphics_draw_drag(this_->gra, NULL);
615 transform_copy(this_->trans, this_->trans_cursor); 622 transform_copy(this_->trans, this_->trans_cursor);
616 graphics_overlay_disable(this_->gra, 0); 623 graphics_overlay_disable(this_->gra, 0);
617 if (!this_->zoomed) 624 if (!this_->zoomed)
625 {
618 navit_set_timeout(this_); 626 navit_set_timeout(this_);
627 }
619 navit_draw(this_); 628 navit_draw(this_);
620 } 629 }
621 else 630 else
622 return 1; 631 return 1;
623 } 632 }
624 return 0; 633 return 0;
625} 634}
626 635
627static void navit_button(void *data, int pressed, int button, struct point *p) 636static void navit_button(void *data, int pressed, int button, struct point *p)
628{ 637{
629#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
630 dbg(0,"+#+:enter\n");
631#endif
632 ////DBG dbg(0,"EEnter\n");
633 struct navit *this = data; 638 struct navit *this = data;
634 // dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events); 639 // dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events);
635 if (!this->ignore_graphics_events) 640 if (!this->ignore_graphics_events)
636 { 641 {
637 if (!this->popup_callback) 642 if (!this->popup_callback)
645 650
646// UNUSED --- 651// UNUSED ---
647// UNUSED --- 652// UNUSED ---
648static void navit_motion_timeout(struct navit *this_) 653static void navit_motion_timeout(struct navit *this_)
649{ 654{
650#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
651 dbg(0,"+#+:enter\n");
652#endif
653 // dbg(0,"EEnter\n");
654 int dx, dy; 655 int dx, dy;
655 656
656 if (this_->drag_bitmap) 657 if (this_->drag_bitmap)
657 { 658 {
658 struct point point; 659 struct point point;
696 return; 697 return;
697} 698}
698 699
699void navit_handle_motion(struct navit *this_, struct point *p) 700void navit_handle_motion(struct navit *this_, struct point *p)
700{ 701{
701#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 702__F_START__
702 dbg(0,"+#+:enter\n"); 703
703#endif
704 ////DBG dbg(0,"EEnter\n");
705 int dx, dy; 704 int dx, dy;
706 705
707 if (this_->button_pressed && !this_->popped) 706 if (this_->button_pressed && !this_->popped)
708 { 707 {
709 dx = (p->x - this_->pressed.x); 708 dx = (p->x - this_->pressed.x);
730 // -------- DISABLE ------- 729 // -------- DISABLE -------
731 // -------- DISABLE ------- 730 // -------- DISABLE -------
732 // -------- DISABLE ------- 731 // -------- DISABLE -------
733 } 732 }
734 } 733 }
734
735__F_END__
735} 736}
736 737
737void navit_motion(void *data, struct point *p) 738void navit_motion(void *data, struct point *p)
738{ 739{
739#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
740 dbg(0,"+#+:enter\n");
741#endif
742 ////DBG dbg(0,"EEnter\n");
743 struct navit *this = data; 740 struct navit *this = data;
744 if (!this->ignore_graphics_events) 741 if (!this->ignore_graphics_events)
745 { 742 {
746 navit_handle_motion(this, p); 743 navit_handle_motion(this, p);
747 } 744 }
748} 745}
749 746
750static void navit_predraw(struct navit *this_) 747void navit_predraw(struct navit *this_)
751{ 748{
752#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 749__F_START__
753 dbg(0,"+#+:enter\n"); 750
754#endif
755 ////DBG dbg(0,"EEnter\n");
756 GList *l; 751 GList *l;
757 struct navit_vehicle *nv; 752 struct navit_vehicle *nv;
758 transform_copy(this_->trans, this_->trans_cursor); 753 transform_copy(this_->trans, this_->trans_cursor);
759 l = this_->vehicles; 754 l = this_->vehicles;
760 while (l) 755 while (l)
763 ////DBG dbg(0,"* here *\n"); 758 ////DBG dbg(0,"* here *\n");
764 ////DBG dbg(0,"vehicle_draw_004\n"); 759 ////DBG dbg(0,"vehicle_draw_004\n");
765 navit_vehicle_draw(this_, nv, NULL); 760 navit_vehicle_draw(this_, nv, NULL);
766 l = g_list_next(l); 761 l = g_list_next(l);
767 } 762 }
763
764__F_END__
768} 765}
769 766
770static void navit_scale(struct navit *this_, long scale, struct point *p, int draw) 767static void navit_scale(struct navit *this_, long scale, struct point *p, int draw)
771{ 768{
772#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
773 dbg(0,"+#+:enter\n");
774#endif
775 //DBG dbg(0,"EEnter\n");
776 struct coord c1, c2, *center; 769 struct coord c1, c2, *center;
777 770
778 if (scale < this_->zoom_min) 771 if (scale < this_->zoom_min)
779 { 772 {
780 scale = this_->zoom_min; 773 scale = this_->zoom_min;
829 * @param speed The vehicles speed in meters per second 822 * @param speed The vehicles speed in meters per second
830 * @param dir The direction into which the vehicle moves 823 * @param dir The direction into which the vehicle moves
831 */ 824 */
832static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw) 825static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw)
833{ 826{
834#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
835 dbg(0,"+#+:enter\n");
836#endif
837 struct point pc; 827 struct point pc;
838 int distance, w, h; 828 int distance, w, h;
839 long new_scale; 829 long new_scale;
840 long scale; 830 long scale;
841 831
915 // return; // Smoothing 905 // return; // Smoothing
916 //} 906 //}
917 907
918 if (new_scale > scale) 908 if (new_scale > scale)
919 { 909 {
910 // zoom out
920 if (new_scale > (scale + 20)) 911 if (new_scale > (scale + 20))
921 { 912 {
922 scale = scale + 10; 913 scale = scale + 10;
923 } 914 }
924 else if (new_scale > (scale + 5)) 915 else if (new_scale > (scale + 5))
930 scale = scale++; 921 scale = scale++;
931 } 922 }
932 } 923 }
933 else if (new_scale < scale) 924 else if (new_scale < scale)
934 { 925 {
926 // zoom in
935 if ((new_scale + 20) < scale) 927 if ((new_scale + 5500) < scale)
928 {
929 scale = scale - 4000;
930 }
931 else if ((new_scale + 1850) < scale)
932 {
933 scale = scale - 1000;
934 }
935 else if ((new_scale + 450) < scale)
936 {
937 scale = scale - 200;
938 }
939 else if ((new_scale + 20) < scale)
936 { 940 {
937 scale = scale - 10; 941 scale = scale - 10;
938 } 942 }
939 else if ((new_scale + 5) < scale) 943 else if ((new_scale + 5) < scale)
940 { 944 {
977 * @param p The invariant point (if set to NULL, default to center) 981 * @param p The invariant point (if set to NULL, default to center)
978 * @returns nothing 982 * @returns nothing
979 */ 983 */
980void navit_zoom_in(struct navit *this_, int factor, struct point *p) 984void navit_zoom_in(struct navit *this_, int factor, struct point *p)
981{ 985{
982#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
983 dbg(0,"+#+:enter\n");
984#endif
985 ////DBG dbg(0,"EEnter\n");
986 long scale = transform_get_scale(this_->trans) / factor; 986 long scale = transform_get_scale(this_->trans) / factor;
987 if (scale < 1) 987 if (scale < 1)
988 { 988 {
989 scale = 1; 989 scale = 1;
990 } 990 }
1000 * @param p The invariant point (if set to NULL, default to center) 1000 * @param p The invariant point (if set to NULL, default to center)
1001 * @returns nothing 1001 * @returns nothing
1002 */ 1002 */
1003void navit_zoom_out(struct navit *this_, int factor, struct point *p) 1003void navit_zoom_out(struct navit *this_, int factor, struct point *p)
1004{ 1004{
1005#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1006 dbg(0,"+#+:enter\n");
1007#endif
1008 ////DBG dbg(0,"EEnter\n");
1009 long scale = transform_get_scale(this_->trans) * factor; 1005 long scale = transform_get_scale(this_->trans) * factor;
1010 ////DBG dbg(0,"zoom out -> scale=%d",scale); 1006 ////DBG dbg(0,"zoom out -> scale=%d",scale);
1011 navit_scale(this_, scale, p, 1); 1007 navit_scale(this_, scale, p, 1);
1012} 1008}
1013 1009
1014int navit_get_cur_pnt(struct navit *this_, struct point *p) 1010int navit_get_cur_pnt(struct navit *this_, struct point *p)
1015{ 1011{
1016#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1017 dbg(0,"+#+:enter\n");
1018#endif
1019 ////DBG dbg(0,"EEnter\n");
1020 return navit_get_cursor_pnt(this_, p, 0, NULL); 1012 return navit_get_cursor_pnt(this_, p, 0, NULL);
1021} 1013}
1022 1014
1023void navit_zoom_in_cursor(struct navit *this_, int factor) 1015void navit_zoom_in_cursor(struct navit *this_, int factor)
1024{ 1016{
1025#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1026 dbg(0,"+#+:enter\n");
1027#endif
1028 ////DBG dbg(0,"EEnter\n");
1029 struct point p; 1017 struct point p;
1030 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) 1018 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL))
1031 { 1019 {
1032 navit_zoom_in(this_, factor, &p); 1020 navit_zoom_in(this_, factor, &p);
1033 this_->vehicle->follow_curr = this_->vehicle->follow; 1021 this_->vehicle->follow_curr = this_->vehicle->follow;
1038 } 1026 }
1039} 1027}
1040 1028
1041void navit_zoom_to_scale(struct navit *this_, int new_scale) 1029void navit_zoom_to_scale(struct navit *this_, int new_scale)
1042{ 1030{
1043#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1044 dbg(0,"+#+:enter\n");
1045#endif
1046 //DBG dbg(0,"EEnter\n");
1047 long scale = transform_get_scale(this_->trans); 1031 long scale = transform_get_scale(this_->trans);
1048 long new_scale_long = new_scale; 1032 long new_scale_long = new_scale;
1049 //DBG dbg(0,"zoom to scale -> old scale=%d",scale); 1033 //DBG dbg(0,"zoom to scale -> old scale=%d",scale);
1050 //DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long); 1034 //DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long);
1051 1035
1052 // only do something if scale changed! 1036 // only do something if scale changed!
1053 if (scale != new_scale_long) 1037 if (scale != new_scale_long)
1054 { 1038 {
1055 navit_scale(this_, new_scale_long, NULL, 1); 1039 navit_scale(this_, new_scale_long, NULL, 1);
1056 } 1040 }
1057#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1058 dbg(0,"+#+:leave\n");
1059#endif
1060} 1041}
1061 1042
1062void navit_zoom_to_scale_with_center_point(struct navit *this_, int new_scale, struct point *p) 1043void navit_zoom_to_scale_with_center_point(struct navit *this_, int new_scale, struct point *p)
1063{ 1044{
1064#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1065 dbg(0,"+#+:enter\n");
1066#endif
1067 //DBG dbg(0,"EEnter\n");
1068 long scale = transform_get_scale(this_->trans); 1045 long scale = transform_get_scale(this_->trans);
1069 long new_scale_long = new_scale; 1046 long new_scale_long = new_scale;
1070 1047
1071 //dbg(0, "zoom to scale -> old scale=%d", scale); 1048 //dbg(0, "zoom to scale -> old scale=%d", scale);
1072 //dbg(0, "zoom to scale -> want scale=%d", new_scale_long); 1049 //dbg(0, "zoom to scale -> want scale=%d", new_scale_long);
1078 } 1055 }
1079} 1056}
1080 1057
1081void navit_zoom_out_cursor(struct navit *this_, int factor) 1058void navit_zoom_out_cursor(struct navit *this_, int factor)
1082{ 1059{
1083#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1084 dbg(0,"+#+:enter\n");
1085#endif
1086 ////DBG dbg(0,"EEnter\n");
1087 struct point p; 1060 struct point p;
1088 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) 1061 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL))
1089 { 1062 {
1090 navit_zoom_out(this_, 2, &p); 1063 navit_zoom_out(this_, 2, &p);
1091 this_->vehicle->follow_curr = this_->vehicle->follow; 1064 this_->vehicle->follow_curr = this_->vehicle->follow;
1096 } 1069 }
1097} 1070}
1098 1071
1099static int navit_cmd_zoom_in(struct navit *this_) 1072static int navit_cmd_zoom_in(struct navit *this_)
1100{ 1073{
1101#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1102 dbg(0,"+#+:enter\n");
1103#endif
1104 ////DBG dbg(0,"EEnter\n");
1105 navit_zoom_in_cursor(this_, 2); 1074 navit_zoom_in_cursor(this_, 2);
1106 return 0; 1075 return 0;
1107} 1076}
1108 1077
1109static int navit_cmd_zoom_out(struct navit *this_) 1078static int navit_cmd_zoom_out(struct navit *this_)
1110{ 1079{
1111#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1112 dbg(0,"+#+:enter\n");
1113#endif
1114 ////DBG dbg(0,"EEnter\n");
1115 navit_zoom_out_cursor(this_, 2); 1080 navit_zoom_out_cursor(this_, 2);
1116 return 0; 1081 return 0;
1117} 1082}
1118 1083
1119static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1084static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1120{ 1085{
1121#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1122 dbg(0,"+#+:enter\n");
1123#endif
1124 ////DBG dbg(0,"EEnter\n");
1125 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) 1086 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
1126 { 1087 {
1127 navit_say(this, in[0]->u.str); 1088 navit_say(this, in[0]->u.str);
1128 } 1089 }
1129} 1090}
1141 * @param valid unused 1102 * @param valid unused
1142 * @returns nothing 1103 * @returns nothing
1143 */ 1104 */
1144static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1105static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1145{ 1106{
1146#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1147 dbg(0,"+#+:enter\n");
1148#endif
1149 ////DBG dbg(0,"EEnter\n");
1150 char*key; 1107 char*key;
1151 struct attr*val; 1108 struct attr*val;
1152 if (!cmd_int_var_hash) 1109 if (!cmd_int_var_hash)
1153 { 1110 {
1154 cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal); 1111 cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal);
1174 * @returns nothing 1131 * @returns nothing
1175 */ 1132 */
1176//TODO free stored attributes on navit_destroy 1133//TODO free stored attributes on navit_destroy
1177static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1134static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1178{ 1135{
1179#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1180 dbg(0,"+#+:enter\n");
1181#endif
1182 ////DBG dbg(0,"EEnter\n");
1183 char*key; 1136 char*key;
1184 struct attr*val; 1137 struct attr*val;
1185 if (!cmd_attr_var_hash) 1138 if (!cmd_attr_var_hash)
1186 { 1139 {
1187 cmd_attr_var_hash = g_hash_table_new(g_str_hash, g_str_equal); 1140 cmd_attr_var_hash = g_hash_table_new(g_str_hash, g_str_equal);
1206 * @param valid unused 1159 * @param valid unused
1207 * @returns nothing 1160 * @returns nothing
1208 */ 1161 */
1209static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1162static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1210{ 1163{
1211#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1212 dbg(0,"+#+:enter\n");
1213#endif
1214 ////DBG dbg(0,"EEnter\n");
1215 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) 1164 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
1216 { 1165 {
1217 if (this->layout_current && this->layout_current->layers) 1166 if (this->layout_current && this->layout_current->layers)
1218 { 1167 {
1219 GList* layers = this->layout_current->layers; 1168 GList* layers = this->layout_current->layers;
1229 layers = g_list_next(layers); 1178 layers = g_list_next(layers);
1230 } 1179 }
1231 } 1180 }
1232 } 1181 }
1233} 1182}
1183
1184
1185void navit_layer_toggle_active(struct navit *this, char *name, int draw)
1186{
1187 if (name)
1188 {
1189 if (this->layout_current && this->layout_current->layers)
1190 {
1191 GList* layers = this->layout_current->layers;
1192 while (layers)
1193 {
1194 struct layer *l = layers->data;
1195 if (l && !strcmp(l->name, name))
1196 {
1197 l->active ^= 1;
1198 if (draw == 1)
1199 {
1200 navit_draw(this);
1201 }
1202 return;
1203 }
1204 layers = g_list_next(layers);
1205 }
1206 }
1207 }
1208}
1209
1210
1234 1211
1235/** 1212/**
1236 * command to set the active state of a named layer of the current layout 1213 * command to set the active state of a named layer of the current layout
1237 * 1214 *
1238 * @param navit The navit instance 1215 * @param navit The navit instance
1241 * @param draw 0 -> dont redraw, 1 -> redraw 1218 * @param draw 0 -> dont redraw, 1 -> redraw
1242 * @returns nothing 1219 * @returns nothing
1243 */ 1220 */
1244void navit_layer_set_active(struct navit *this, char *name, int active, int draw) 1221void navit_layer_set_active(struct navit *this, char *name, int active, int draw)
1245{ 1222{
1246#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1247 dbg(0,"+#+:enter\n");
1248#endif
1249 //dbg(0,"EEnter\n");
1250 if (name) 1223 if (name)
1251 { 1224 {
1252 if (this->layout_current && this->layout_current->layers) 1225 if (this->layout_current && this->layout_current->layers)
1253 { 1226 {
1254 GList* layers = this->layout_current->layers; 1227 GList* layers = this->layout_current->layers;
1280 * @param valid unused 1253 * @param valid unused
1281 * @returns nothing 1254 * @returns nothing
1282 */ 1255 */
1283static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1256static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1284{ 1257{
1285#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1286 dbg(0,"+#+:enter\n");
1287#endif
1288 ////DBG dbg(0,"EEnter\n");
1289 struct attr **list = g_new0(struct attr *,2); 1258 struct attr **list = g_new0(struct attr *,2);
1290 struct attr*val = g_new0(struct attr,1); 1259 struct attr*val = g_new0(struct attr,1);
1291 struct mapset* ms; 1260 struct mapset* ms;
1292 struct map_selection sel; 1261 struct map_selection sel;
1293 const int selection_range = 10; 1262 const int selection_range = 10;
1372 * @param valid unused 1341 * @param valid unused
1373 * @returns nothing 1342 * @returns nothing
1374 */ 1343 */
1375static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1344static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1376{ 1345{
1377#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1378 dbg(0,"+#+:enter\n");
1379#endif
1380 ////DBG dbg(0,"EEnter\n");
1381 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name 1346 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name
1382 in[1] && ATTR_IS_ITEM(in[1]->type) && //item 1347 in[1] && ATTR_IS_ITEM(in[1]->type) && //item
1383 in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str 1348 in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str
1384 in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str 1349 in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str
1385 ) 1350 )
1445 * @param valid unused 1410 * @param valid unused
1446 * @returns nothing 1411 * @returns nothing
1447 */ 1412 */
1448static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1413static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1449{ 1414{
1450#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1451 dbg(0,"+#+:enter\n");
1452#endif
1453 ////DBG dbg(0,"EEnter\n");
1454 struct attr **list = g_new0(struct attr *,2); 1415 struct attr **list = g_new0(struct attr *,2);
1455 if (!cmd_int_var_hash) 1416 if (!cmd_int_var_hash)
1456 { 1417 {
1457 struct attr*val = g_new0(struct attr,1); 1418 struct attr*val = g_new0(struct attr,1);
1458 val->type = attr_type_item_begin; 1419 val->type = attr_type_item_begin;
1488 * @param valid unused 1449 * @param valid unused
1489 * @returns nothing 1450 * @returns nothing
1490 */ 1451 */
1491static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1452static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1492{ 1453{
1493#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1494 dbg(0,"+#+:enter\n");
1495#endif
1496 ////DBG dbg(0,"EEnter\n");
1497 struct attr **list = g_new0(struct attr *,2); 1454 struct attr **list = g_new0(struct attr *,2);
1498 if (!cmd_int_var_hash) 1455 if (!cmd_int_var_hash)
1499 { 1456 {
1500 struct attr*val = g_new0(struct attr,1); 1457 struct attr*val = g_new0(struct attr,1);
1501 val->type = attr_type_int_begin; 1458 val->type = attr_type_int_begin;
1533 * @param valid unused 1490 * @param valid unused
1534 * @returns nothing 1491 * @returns nothing
1535 */ 1492 */
1536static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1493static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1537{ 1494{
1538#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1539 dbg(0,"+#+:enter\n");
1540#endif
1541 ////DBG dbg(0,"EEnter\n");
1542 if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) 1495 if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type))
1543 { 1496 {
1544 struct attr*val = g_new(struct attr,1); 1497 struct attr*val = g_new(struct attr,1);
1545 attr_dup_content(in[0], val); 1498 attr_dup_content(in[0], val);
1546 cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val); 1499 cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val);
1557 * @param valid unused 1510 * @param valid unused
1558 * @returns nothing 1511 * @returns nothing
1559 */ 1512 */
1560static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1513static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1561{ 1514{
1562#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1563 dbg(0,"+#+:enter\n");
1564#endif
1565 ////DBG dbg(0,"EEnter\n");
1566 struct attr **list = g_new0(struct attr *,2); 1515 struct attr **list = g_new0(struct attr *,2);
1567 if (!cmd_int_var_stack) 1516 if (!cmd_int_var_stack)
1568 { 1517 {
1569 struct attr*val = g_new0(struct attr,1); 1518 struct attr*val = g_new0(struct attr,1);
1570 val->type = attr_type_int_begin; 1519 val->type = attr_type_int_begin;
1590 * @param valid unused 1539 * @param valid unused
1591 * @returns nothing 1540 * @returns nothing
1592 */ 1541 */
1593static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1542static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1594{ 1543{
1595#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1596 dbg(0,"+#+:enter\n");
1597#endif
1598 ////DBG dbg(0,"EEnter\n");
1599 struct attr **list; 1544 struct attr **list;
1600 struct attr *attr = g_new0(struct attr ,1); 1545 struct attr *attr = g_new0(struct attr ,1);
1601 attr->type = attr_type_int_begin; 1546 attr->type = attr_type_int_begin;
1602 if (!cmd_int_var_stack) 1547 if (!cmd_int_var_stack)
1603 { 1548 {
1613 cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); 1558 cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack);
1614} 1559}
1615 1560
1616static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1561static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1617{ 1562{
1618#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1619 dbg(0,"+#+:enter\n");
1620#endif
1621 ////DBG dbg(0,"EEnter\n");
1622 struct pcoord pc; 1563 struct pcoord pc;
1623 char *description = NULL; 1564 char *description = NULL;
1624 if (!in) 1565 if (!in)
1625 return; 1566 return;
1626 if (!in[0]) 1567 if (!in[0])
1661 navit_set_destination(this, &pc, description, 1); 1602 navit_set_destination(this, &pc, description, 1);
1662} 1603}
1663 1604
1664static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1605static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1665{ 1606{
1666#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1667 dbg(0,"+#+:enter\n");
1668#endif
1669 ////DBG dbg(0,"EEnter\n");
1670 struct attr attr; 1607 struct attr attr;
1671 attr.type = attr_type_string_begin; 1608 attr.type = attr_type_string_begin;
1672 attr.u.str = "Fix me"; 1609 attr.u.str = "Fix me";
1673 if (out) 1610 if (out)
1674 { 1611 {
1686 * @param valid unused 1623 * @param valid unused
1687 * @returns nothing 1624 * @returns nothing
1688 */ 1625 */
1689static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1626static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1690{ 1627{
1691#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1692 dbg(0,"+#+:enter\n");
1693#endif
1694 ////DBG dbg(0,"EEnter\n");
1695 struct attr attr; 1628 struct attr attr;
1696 gchar *ret, *sep; 1629 gchar *ret, *sep;
1697 int i; 1630 int i;
1698 attr.type = attr_type_string_begin; 1631 attr.type = attr_type_string_begin;
1699 attr.u.str = NULL; 1632 attr.u.str = NULL;
1729 * @param valid unused 1662 * @param valid unused
1730 * @returns nothing 1663 * @returns nothing
1731 */ 1664 */
1732static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1665static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1733{ 1666{
1734#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1735 dbg(0,"+#+:enter\n");
1736#endif
1737 ////DBG dbg(0,"EEnter\n");
1738 int i, j, nparms, nvalid; 1667 int i, j, nparms, nvalid;
1739 const char ** argv = NULL; 1668 const char ** argv = NULL;
1740 struct spawn_process_info *pi; 1669 struct spawn_process_info *pi;
1741 1670
1742 nparms = 0; 1671 nparms = 0;
1793 commands[] = 1722 commands[] =
1794 { { "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) }, }; 1723 { { "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) }, };
1795 1724
1796void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) 1725void navit_command_add_table(struct navit*this_, struct command_table *commands, int count)
1797{ 1726{
1798#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1799 dbg(0,"+#+:enter\n");
1800#endif
1801 ////DBG dbg(0,"EEnter\n");
1802 command_add_table(this_->attr_cbl, commands, count, this_); 1727 command_add_table(this_->attr_cbl, commands, count, this_);
1803} 1728}
1729
1804 1730
1805struct navit * 1731struct navit *
1806navit_new(struct attr *parent, struct attr **attrs) 1732navit_new(struct attr *parent, struct attr **attrs)
1807{ 1733{
1808#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1809 dbg(0,"+#+:enter\n");
1810#endif
1811
1812 dbg(0, "+#+:enter\n");
1813
1814 struct navit *this_=g_new0(struct navit, 1); 1734 struct navit *this_=g_new0(struct navit, 1);
1815 struct pcoord center; 1735 struct pcoord center;
1816 struct coord co; 1736 struct coord co;
1817 struct coord_geo g; 1737 struct coord_geo g;
1818 enum projection pro = projection_mg; 1738 enum projection pro = projection_mg;
1819 int zoom = 256; 1739 int zoom = 256;
1820 g.lat = 53.13; 1740 g.lat = 53.13;
1821 g.lng = 11.70; 1741 g.lng = 11.70;
1822 1742
1743
1744 global_demo_vehicle = 0;
1745 global_demo_vehicle_short_switch = 0;
1746
1747
1748 // set base for timestamps
1749 struct timeval tv2;
1750 if (gettimeofday(&tv2, NULL) == -1)
1751 {
1752 global_last_spoken_base = 0;
1753 }
1754 else
1755 {
1756 global_last_spoken_base = (long)tv2.tv_sec;
1757 }
1758
1759 global_debug_coord_list = g_new0(struct coord, (2 * (MAX_DEBUG_COORDS + 2)));
1760 global_debug_coord_list_items = 0;
1761
1762 global_debug_route_seg_winner_start.x = 0;
1763 global_debug_route_seg_winner_start.y = 0;
1764 global_debug_route_seg_winner_end.x = 0;
1765 global_debug_route_seg_winner_end.y = 0;
1766
1767 global_debug_seg_winner_start.x = 0;
1768 global_debug_seg_winner_start.y = 0;
1769 global_debug_seg_winner_end.x = 0;
1770 global_debug_seg_winner_end.y = 0;
1771
1772 global_debug_route_seg_winner_p_start.x = 0;
1773 global_debug_route_seg_winner_p_start.y = 0;
1774
1775 global_debug_seg_winner_p_start.x = 0;
1776 global_debug_seg_winner_p_start.y = 0;
1777
1778 global_debug_seg_route_start.x = 0;
1779 global_debug_seg_route_start.y = 0;
1780
1781 global_debug_seg_route_end.x = 0;
1782 global_debug_seg_route_end.y = 0;
1783
1784
1785
1823 this_->self.type = attr_navit; 1786 this_->self.type = attr_navit;
1824 this_->self.u.navit = this_; 1787 this_->self.u.navit = this_;
1825 this_->attr_cbl = callback_list_new(); 1788 this_->attr_cbl = callback_list_new("navit_new:this_->attr_cbl");
1826 1789
1827 this_->orientation = -1; 1790 this_->orientation = -1;
1828 this_->tracking_flag = 1; 1791 this_->tracking_flag = 1;
1829 this_->recentdest_count = 10; 1792 this_->recentdest_count = 10;
1830 this_->osd_configuration = -1; 1793 this_->osd_configuration = -1;
1884 return this_; 1847 return this_;
1885} 1848}
1886 1849
1887static int navit_set_gui(struct navit *this_, struct gui *gui) 1850static int navit_set_gui(struct navit *this_, struct gui *gui)
1888{ 1851{
1889#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1890 dbg(0,"+#+:enter\n");
1891#endif
1892 ////DBG dbg(0,"EEnter\n");
1893 if (this_->gui) 1852 if (this_->gui)
1894 return 0; 1853 return 0;
1854
1895 this_->gui = gui; 1855 this_->gui = gui;
1856
1896 if (gui_has_main_loop(this_->gui)) 1857 if (gui_has_main_loop(this_->gui))
1897 { 1858 {
1898 if (!main_loop_gui) 1859 if (!main_loop_gui)
1899 { 1860 {
1900 main_loop_gui = this_->gui; 1861 main_loop_gui = this_->gui;
1908 return 1; 1869 return 1;
1909} 1870}
1910 1871
1911void navit_add_message(struct navit *this_, char *message) 1872void navit_add_message(struct navit *this_, char *message)
1912{ 1873{
1913#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1914 dbg(0,"+#+:enter\n");
1915#endif
1916 ////DBG dbg(0,"EEnter\n");
1917 // message_new(this_->messages, message); 1874 // message_new(this_->messages, message);
1918} 1875}
1919 1876
1920struct message *navit_get_messages(struct navit *this_) 1877struct message *navit_get_messages(struct navit *this_)
1921{ 1878{
1922#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1923 dbg(0,"+#+:enter\n");
1924#endif
1925 ////DBG dbg(0,"EEnter\n");
1926 // return message_get(this_->messages); 1879 // return message_get(this_->messages);
1927} 1880}
1928 1881
1929static int navit_set_graphics(struct navit *this_, struct graphics *gra) 1882static int navit_set_graphics(struct navit *this_, struct graphics *gra)
1930{ 1883{
1931#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1932 dbg(0,"+#+:enter\n");
1933#endif
1934 ////DBG dbg(0,"EEnter\n");
1935 if (this_->gra) 1884 if (this_->gra)
1885 {
1936 return 0; 1886 return 0;
1887 }
1888
1937 this_->gra = gra; 1889 this_->gra = gra;
1938 1890
1939 /* 1891 /*
1940 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_); 1892 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_);
1941 graphics_add_callback(gra, this_->resize_callback); 1893 graphics_add_callback(gra, this_->resize_callback);
1948 // this draw the vehicle // very stupid 1900 // this draw the vehicle // very stupid
1949 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_); 1901 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_);
1950 callback_add_names(this_->predraw_callback, "navit_set_graphics", "navit_predraw"); 1902 callback_add_names(this_->predraw_callback, "navit_set_graphics", "navit_predraw");
1951 graphics_add_callback(gra, this_->predraw_callback); 1903 graphics_add_callback(gra, this_->predraw_callback);
1952 1904
1953 ////DBG dbg(0,"111111111\n");
1954 return 1; 1905 return 1;
1955} 1906}
1956 1907
1957struct graphics * 1908struct graphics *
1958navit_get_graphics(struct navit *this_) 1909navit_get_graphics(struct navit *this_)
1959{ 1910{
1960#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1961 dbg(0,"+#+:enter\n");
1962#endif
1963 ////DBG dbg(0,"EEnter\n");
1964 return this_->gra; 1911 return this_->gra;
1965} 1912}
1966 1913
1967struct vehicleprofile * 1914struct vehicleprofile *
1968navit_get_vehicleprofile(struct navit *this_) 1915navit_get_vehicleprofile(struct navit *this_)
1969{ 1916{
1970#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1971 dbg(0,"+#+:enter\n");
1972#endif
1973 ////DBG dbg(0,"EEnter\n");
1974 return this_->vehicleprofile; 1917 return this_->vehicleprofile;
1975} 1918}
1976 1919
1977GList * 1920GList *
1978navit_get_vehicleprofiles(struct navit *this_) 1921navit_get_vehicleprofiles(struct navit *this_)
1979{ 1922{
1980#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1981 dbg(0,"+#+:enter\n");
1982#endif
1983 ////DBG dbg(0,"EEnter\n");
1984 return this_->vehicleprofiles; 1923 return this_->vehicleprofiles;
1985} 1924}
1986 1925
1987static void navit_projection_set(struct navit *this_, enum projection pro, int draw) 1926static void navit_projection_set(struct navit *this_, enum projection pro, int draw)
1988{ 1927{
1989#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1928
1990 dbg(0,"+#+:enter\n"); 1929
1991#endif
1992 ////DBG dbg(0,"EEnter\n"); 1930 ////DBG dbg(0,"EEnter\n");
1993 struct coord_geo g; 1931 struct coord_geo g;
1994 struct coord *c; 1932 struct coord *c;
1995 1933
1996 c = transform_center(this_->trans); 1934 c = transform_center(this_->trans);
2011 * @param description A label which allows the user to later identify this destination in the former destinations selection 1949 * @param description A label which allows the user to later identify this destination in the former destinations selection
2012 * @returns nothing 1950 * @returns nothing
2013 */ 1951 */
2014void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async) 1952void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async)
2015{ 1953{
2016#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1954
2017 dbg(0,"+#+:enter\n"); 1955
2018#endif
2019 ////DBG dbg(0,"EEnter\n"); 1956 ////DBG dbg(0,"EEnter\n");
2020 char *destination_file; 1957 char *destination_file;
2021 if (c) 1958 if (c)
2022 { 1959 {
2023 this_->destination = *c; 1960 this_->destination = *c;
2053 * @param description A dummy string 1990 * @param description A dummy string
2054 * @returns nothing 1991 * @returns nothing
2055 */ 1992 */
2056void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async) 1993void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async)
2057{ 1994{
2058#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1995
2059 dbg(0,"+#+:enter\n"); 1996
2060#endif
2061 if (this_->destination_valid == 1) 1997 if (this_->destination_valid == 1)
2062 { 1998 {
2063 //int count = 0; 1999 //int count = 0;
2064 //count = g_list_length(this_->route->destinations); 2000 //count = g_list_length(this_->route->destinations);
2065 //DBG dbg(0, "count=%d\n", count); 2001 //DBG dbg(0, "count=%d\n", count);
2086 * @param description A label which allows the user to later identify this destination in the former destinations selection 2022 * @param description A label which allows the user to later identify this destination in the former destinations selection
2087 * @returns nothing 2023 * @returns nothing
2088 */ 2024 */
2089void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async) 2025void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async)
2090{ 2026{
2091#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2027
2092 dbg(0,"+#+:enter\n"); 2028
2093#endif
2094 ////DBG dbg(0,"EEnter\n"); 2029 ////DBG dbg(0,"EEnter\n");
2095 char *destination_file; 2030 char *destination_file;
2096 if (c && count) 2031 if (c && count)
2097 { 2032 {
2098 this_->destination = c[count - 1]; 2033 this_->destination = c[count - 1];
2125 * @param this_ The navit struct whose route should be checked. 2060 * @param this_ The navit struct whose route should be checked.
2126 * @return True if the route is set, false otherwise. 2061 * @return True if the route is set, false otherwise.
2127 */ 2062 */
2128int navit_check_route(struct navit *this_) 2063int navit_check_route(struct navit *this_)
2129{ 2064{
2130#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2065
2131 dbg(0,"+#+:enter\n"); 2066
2132#endif
2133 ////DBG dbg(0,"EEnter\n"); 2067 ////DBG dbg(0,"EEnter\n");
2134 if (this_->route) 2068 if (this_->route)
2135 { 2069 {
2136 return route_get_path_set(this_->route); 2070 return route_get_path_set(this_->route);
2137 } 2071 }
2139 return 0; 2073 return 0;
2140} 2074}
2141 2075
2142static int navit_former_destinations_active(struct navit *this_) 2076static int navit_former_destinations_active(struct navit *this_)
2143{ 2077{
2144#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2078
2145 dbg(0,"+#+:enter\n"); 2079
2146#endif
2147 ////DBG dbg(0,"EEnter\n"); 2080 ////DBG dbg(0,"EEnter\n");
2148 2081
2149 return 0; 2082 return 0;
2150 // disable this function!! 2083 // disable this function!!
2151 2084
2168 return active; 2101 return active;
2169} 2102}
2170 2103
2171static void navit_add_former_destinations_from_file(struct navit *this_) 2104static void navit_add_former_destinations_from_file(struct navit *this_)
2172{ 2105{
2173#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2106
2174 dbg(0,"+#+:enter\n"); 2107
2175#endif
2176 ////DBG dbg(0,"EEnter\n"); 2108 ////DBG dbg(0,"EEnter\n");
2177 char *destination_file = bookmarks_get_destination_file(FALSE); 2109 char *destination_file = bookmarks_get_destination_file(FALSE);
2178 struct attr *attrs[4]; 2110 struct attr *attrs[4];
2179 struct map_rect *mr; 2111 struct map_rect *mr;
2180 struct item *item; 2112 struct item *item;
2235 } 2167 }
2236} 2168}
2237 2169
2238void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) 2170void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...)
2239{ 2171{
2240#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2172
2241 dbg(0,"+#+:enter\n"); 2173
2242#endif
2243 ////DBG dbg(0,"EEnter\n"); 2174 ////DBG dbg(0,"EEnter\n");
2244 va_list ap; 2175 va_list ap;
2245 char *str1, *str2; 2176 char *str1, *str2;
2246 va_start(ap, fmt); 2177 va_start(ap, fmt);
2247 if (this_->textfile_debug_log && this_->vehicle) 2178 if (this_->textfile_debug_log && this_->vehicle)
2255 va_end(ap); 2186 va_end(ap);
2256} 2187}
2257 2188
2258void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...) 2189void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...)
2259{ 2190{
2260#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2191
2261 dbg(0,"+#+:enter\n"); 2192
2262#endif
2263 ////DBG dbg(0,"EEnter\n"); 2193 ////DBG dbg(0,"EEnter\n");
2264 va_list ap; 2194 va_list ap;
2265 char *str1, *str2; 2195 char *str1, *str2;
2266 va_start(ap, fmt); 2196 va_start(ap, fmt);
2267 if (this_->textfile_debug_log && this_->vehicle) 2197 if (this_->textfile_debug_log && this_->vehicle)
2275 va_end(ap); 2205 va_end(ap);
2276} 2206}
2277 2207
2278void navit_say(struct navit *this_, char *text) 2208void navit_say(struct navit *this_, char *text)
2279{ 2209{
2280#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2210
2281 dbg(0,"+#+:enter\n"); 2211
2282#endif
2283 ////DBG dbg(0,"EEnter\n"); 2212 ////DBG dbg(0,"EEnter\n");
2284 if (this_->speech) 2213 if (this_->speech)
2285 { 2214 {
2215 //dbg(0,"say(1) s=%s\n", text);
2286 speech_say(this_->speech, text); 2216 speech_say(this_->speech, text);
2287 } 2217 }
2288} 2218}
2289 2219
2290/** 2220/**
2291 * @brief Toggles the navigation announcer for navit 2221 * @brief Toggles the navigation announcer for navit
2292 * @param this_ The navit object 2222 * @param this_ The navit object
2293 */ 2223 */
2294static void navit_cmd_announcer_toggle(struct navit *this_) 2224static void navit_cmd_announcer_toggle(struct navit *this_)
2295{ 2225{
2296#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2226
2297 dbg(0,"+#+:enter\n"); 2227
2298#endif
2299 struct attr attr, speechattr; 2228 struct attr attr, speechattr;
2300 2229
2301 // search for the speech attribute 2230 // search for the speech attribute
2302 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2231 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
2303 return; 2232 return;
2322 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2251 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
2323} 2252}
2324 2253
2325void navit_cmd_announcer_on(struct navit *this_) 2254void navit_cmd_announcer_on(struct navit *this_)
2326{ 2255{
2327#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2256
2328 dbg(0,"+#+:enter\n"); 2257
2329#endif
2330 struct attr attr, speechattr; 2258 struct attr attr, speechattr;
2331 2259
2332 // search for the speech attribute 2260 // search for the speech attribute
2333 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2261 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
2334 return; 2262 return;
2344 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2272 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
2345} 2273}
2346 2274
2347void navit_cmd_announcer_off(struct navit *this_) 2275void navit_cmd_announcer_off(struct navit *this_)
2348{ 2276{
2349#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2277
2350 dbg(0,"+#+:enter\n"); 2278
2351#endif
2352 struct attr attr, speechattr; 2279 struct attr attr, speechattr;
2353 2280
2354 // search for the speech attribute 2281 // search for the speech attribute
2355 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2282 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
2356 return; 2283 return;
2366 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2293 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
2367} 2294}
2368 2295
2369void navit_speak(struct navit *this_) 2296void navit_speak(struct navit *this_)
2370{ 2297{
2371#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2298
2372 dbg(0,"+#+:enter\n"); 2299
2373#endif
2374 ////DBG dbg(0,"EEnter\n"); 2300 ////DBG dbg(0,"EEnter\n");
2375 struct navigation *nav = this_->navigation; 2301 struct navigation *nav = this_->navigation;
2376 struct map *map = NULL; 2302 struct map *map = NULL;
2377 struct map_rect *mr = NULL; 2303 struct map_rect *mr = NULL;
2378 struct item *item; 2304 struct item *item;
2379 struct attr attr; 2305 struct attr attr;
2380 2306
2381 if (!speech_get_attr(this_->speech, attr_active, &attr, NULL)) 2307 if (!speech_get_attr(this_->speech, attr_active, &attr, NULL))
2308 {
2382 attr.u.num = 1; 2309 attr.u.num = 1;
2310 }
2311
2383 // dbg(1, "this_.speech->active %i\n", attr.u.num); 2312 // dbg(1, "this_.speech->active %i\n", attr.u.num);
2313
2384 if (!attr.u.num) 2314 if (!attr.u.num)
2315 {
2385 return; 2316 return;
2317 }
2386 2318
2387 if (nav) 2319 if (nav)
2388 map = navigation_get_map(nav); 2320 map = navigation_get_map(nav);
2321
2389 if (map) 2322 if (map)
2390 mr = map_rect_new(map, NULL); 2323 mr = map_rect_new(map, NULL);
2324
2391 if (mr) 2325 if (mr)
2392 { 2326 {
2393 while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none)) 2327 while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none))
2394 ; 2328 ;
2329
2395 if (item && item_attr_get(item, attr_navigation_speech, &attr)) 2330 if (item && item_attr_get(item, attr_navigation_speech, &attr))
2396 { 2331 {
2332 //dbg(0,"say(2) s=X%sX\n", attr.u.str);
2333 if (strlen(attr.u.str) > 0)
2334 {
2397 speech_say(this_->speech, attr.u.str); 2335 speech_say(this_->speech, attr.u.str);
2336 }
2398 //navit_add_message(this_, attr.u.str); 2337 //navit_add_message(this_, attr.u.str);
2399 navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str); 2338 // navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str);
2400 } 2339 }
2401 map_rect_destroy(mr); 2340 map_rect_destroy(mr);
2402 } 2341 }
2403} 2342}
2404 2343
2405static void navit_window_roadbook_update(struct navit *this_) 2344static void navit_window_roadbook_update(struct navit *this_)
2406{ 2345{
2407#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2346
2408 dbg(0,"+#+:enter\n"); 2347
2409#endif
2410 ////DBG dbg(0,"EEnter\n"); 2348 ////DBG dbg(0,"EEnter\n");
2411 struct navigation *nav = this_->navigation; 2349 struct navigation *nav = this_->navigation;
2412 struct map *map = NULL; 2350 struct map *map = NULL;
2413 struct map_rect *mr = NULL; 2351 struct map_rect *mr = NULL;
2414 struct item *item; 2352 struct item *item;
2501 datawindow_mode(this_->roadbook_window, 0); 2439 datawindow_mode(this_->roadbook_window, 0);
2502} 2440}
2503 2441
2504void navit_window_roadbook_destroy(struct navit *this_) 2442void navit_window_roadbook_destroy(struct navit *this_)
2505{ 2443{
2506#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2444
2507 dbg(0,"+#+:enter\n"); 2445
2508#endif
2509 ////DBG dbg(0, "enter\n"); 2446 ////DBG dbg(0, "enter\n");
2510 navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); 2447 navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
2511 this_->roadbook_window = NULL; 2448 this_->roadbook_window = NULL;
2512 this_->roadbook_callback = NULL; 2449 this_->roadbook_callback = NULL;
2513} 2450}
2514 2451
2515void navit_window_roadbook_new(struct navit *this_) 2452void navit_window_roadbook_new(struct navit *this_)
2516{ 2453{
2517#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2454
2518 dbg(0,"+#+:enter\n"); 2455
2519#endif
2520 if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) 2456 if (!this_->gui || this_->roadbook_callback || this_->roadbook_window)
2521 { 2457 {
2522 return; 2458 return;
2523 } 2459 }
2524 2460
2528 navit_window_roadbook_update(this_); 2464 navit_window_roadbook_update(this_);
2529} 2465}
2530 2466
2531void navit_remove_all_maps(struct navit *this_) 2467void navit_remove_all_maps(struct navit *this_)
2532{ 2468{
2533#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2469
2534 dbg(0,"+#+:enter\n"); 2470
2535#endif 2471
2472 dbg(0,"ROUTExxPOSxx:navit_remove_all_maps:enter\n");
2473
2536 struct mapset *ms; 2474 struct mapset *ms;
2537 struct map *map3; 2475 struct map *map3;
2538 2476
2539 // hold map drawing 2477 // hold map drawing
2540 // this_->ready = 1; 2478 // this_->ready = 1;
2553 2491
2554 if (this_->route) 2492 if (this_->route)
2555 { 2493 {
2556 struct attr callback; 2494 struct attr callback;
2557 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 2495 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
2496
2497
2558 callback.type = attr_callback; 2498 callback.type = attr_callback;
2559 callback.u.callback = this_->route_cb; 2499 callback.u.callback = this_->route_cb;
2560 route_remove_attr(this_->route, &callback); 2500 route_remove_attr(this_->route, &callback);
2561 2501
2562 this_->route->ms = NULL; 2502 this_->route->ms = NULL;
2656void navit_map_active_flag(struct navit *this_, int activate, const char *mapname) 2596void navit_map_active_flag(struct navit *this_, int activate, const char *mapname)
2657{ 2597{
2658 // activate = 0 -> deactivate 2598 // activate = 0 -> deactivate
2659 // activate = 1 -> activate 2599 // activate = 1 -> activate
2660 2600
2661#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2601
2662 dbg(0,"+#+:enter\n"); 2602
2663#endif
2664 struct mapset *ms; 2603 struct mapset *ms;
2665 struct map *map3; 2604 struct map *map3;
2666 2605
2667 if (this_->mapsets) 2606 if (this_->mapsets)
2668 { 2607 {
2691 2630
2692} 2631}
2693 2632
2694void navit_add_all_maps(struct navit *this_) 2633void navit_add_all_maps(struct navit *this_)
2695{ 2634{
2696#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 2635__F_START__
2697 dbg(0,"+#+:enter\n"); 2636
2698#endif
2699 struct map *map3; 2637 struct map *map3;
2700 2638
2701 if (this_->mapsets) 2639 if (this_->mapsets)
2702 { 2640 {
2703 //DBG dbg(0, "xADDx all maps - start\n"); 2641 //DBG dbg(0, "xADDx all maps - start\n");
2712 struct map *map2; 2650 struct map *map2;
2713 struct attr map2_attr; 2651 struct attr map2_attr;
2714 struct attr *attrs[4]; 2652 struct attr *attrs[4];
2715 char *map_file; 2653 char *map_file;
2716 2654
2655 dbg(0, "001\n");
2656
2717 parent.type = attr_navit; 2657 parent.type = attr_navit;
2718 parent.u.navit = this_; 2658 parent.u.navit = this_;
2719 type.type = attr_type; 2659 type.type = attr_type;
2720 type.u.str = "binfile"; 2660 type.u.str = "binfile";
2721 data.type = attr_data; 2661 data.type = attr_data;
2840 } 2780 }
2841 g_free(map_file); 2781 g_free(map_file);
2842 // traffic map -------------------- 2782 // traffic map --------------------
2843 2783
2844 2784
2785 dbg(0, "002\n");
2786
2845 2787
2846 // world map2 -------------------- 2788 // world map2 --------------------
2847 parent.type = attr_navit; 2789 parent.type = attr_navit;
2848 parent.u.navit = this_; 2790 parent.u.navit = this_;
2849 type.type = attr_type; 2791 type.type = attr_type;
2912 active.u.num = 0; // by default deactivate routing on this map 2854 active.u.num = 0; // by default deactivate routing on this map
2913 map_set_attr(map2, &active); 2855 map_set_attr(map2, &active);
2914 } 2856 }
2915 g_free(map_file); 2857 g_free(map_file);
2916 // world map5 -------------------- 2858 // world map5 --------------------
2859
2860 dbg(0, "003\n");
2917 2861
2918 2862
2919#if 0 2863#if 0
2920 // world map6 -------------------- 2864 // world map6 --------------------
2921 parent.type = attr_navit; 2865 parent.type = attr_navit;
2950 map_set_attr(map2, &active); 2894 map_set_attr(map2, &active);
2951 } 2895 }
2952 g_free(map_file); 2896 g_free(map_file);
2953 // world map6 -------------------- 2897 // world map6 --------------------
2954#endif 2898#endif
2899
2900 dbg(0, "004\n");
2955 2901
2956 2902
2957 int i = 1; 2903 int i = 1;
2958 for (i = 1; i < 10; i++) 2904 for (i = 1; i < 10; i++)
2959 { 2905 {
3064 3010
3065 //int async = 0; 3011 //int async = 0;
3066 //transform_setup_source_rect(this_->trans); 3012 //transform_setup_source_rect(this_->trans);
3067 //graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); 3013 //graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1);
3068 3014
3015 if (this_->mapsets)
3016 {
3017 dbg(0, "005\n");
3018
3069 struct displaylist *dl = navit_get_displaylist(this_); 3019 struct displaylist *dl = navit_get_displaylist(this_);
3020 dbg(0, "005a dl=%p\n", dl);
3021 dbg(0, "005a1 ms=%p\n", this_->mapsets);
3022 dbg(0, "005a2 ms=%p\n", this_->mapsets->data);
3070 dl->ms = this_->mapsets->data; 3023 dl->ms = this_->mapsets->data;
3024 dbg(0, "005b\n");
3071 dl->m = NULL; 3025 dl->m = NULL;
3026 dbg(0, "005c\n");
3072 dl->msh = NULL; 3027 dl->msh = NULL;
3073 3028
3074 if (this_->route) 3029 dbg(0, "005.1\n");
3075 {
3076 struct mapset *ms;
3077 ms = this_->mapsets->data;
3078 route_set_mapset(this_->route, ms);
3079 3030
3080 struct attr callback;
3081 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
3082 callback_add_names(this_->route_cb, "navit_add_all_maps", "navit_redraw_route");
3083 callback.type = attr_callback;
3084 callback.u.callback = this_->route_cb;
3085 route_add_attr(this_->route, &callback);
3086 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans));
3087 }
3088
3089 if (this_->tracking)
3090 {
3091 struct mapset *ms;
3092 ms = this_->mapsets->data;
3093
3094 tracking_set_mapset(this_->tracking, ms);
3095 if (this_->route) 3031 if (this_->route)
3096 { 3032 {
3033 dbg(0, "005.2\n");
3034
3035 struct mapset *ms;
3036 dbg(0, "005.3\n");
3037 ms = this_->mapsets->data;
3038 dbg(0, "005.4\n");
3039 route_set_mapset(this_->route, ms);
3040
3041 dbg(0, "005.5\n");
3042
3043 struct attr callback;
3044 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
3045 dbg(0, "005.6\n");
3046 callback_add_names(this_->route_cb, "navit_add_all_maps", "navit_redraw_route");
3047 dbg(0, "005.7\n");
3048 callback.type = attr_callback;
3049 dbg(0, "005.8\n");
3050 callback.u.callback = this_->route_cb;
3051 dbg(0, "005.9\n");
3052 route_add_attr(this_->route, &callback);
3053 dbg(0, "005.10\n");
3054 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans));
3055
3056
3057 }
3058
3059
3060 dbg(0, "006\n");
3061
3062
3063 if (this_->tracking)
3064 {
3065 struct mapset *ms;
3066 ms = this_->mapsets->data;
3067
3068 tracking_set_mapset(this_->tracking, ms);
3069 if (this_->route)
3070 {
3097 tracking_set_route(this_->tracking, this_->route); 3071 tracking_set_route(this_->tracking, this_->route);
3098 } 3072 }
3073 }
3074
3099 } 3075 }
3100 3076
3101 // ready for drawing map 3077 // ready for drawing map
3102 // this_->ready = 3; 3078 // this_->ready = 3;
3103 3079
3104 // draw map 3080 // draw map
3105 // navit_draw(this_); 3081 // navit_draw(this_);
3082
3083__F_END__
3106} 3084}
3107 3085
3108void navit_reload_maps(struct navit *this_) 3086void navit_reload_maps(struct navit *this_)
3109{ 3087{
3110#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3088
3111 dbg(0,"+#+:enter\n"); 3089
3112#endif 3090
3091 dbg(0,"ROUTExxPOSxx:navit_reload_maps:enter\n");
3092
3113 navit_remove_all_maps(this_); 3093 navit_remove_all_maps(this_);
3114 navit_add_all_maps(this_); 3094 navit_add_all_maps(this_);
3115} 3095}
3116 3096
3097
3098// --- forward def ----
3099void navit_set_vehicle_position_to_screen_center(struct navit *this_);
3100// --- forward def ----
3101
3117void navit_init(struct navit *this_) 3102void navit_init(struct navit *this_)
3118{ 3103{
3119#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3104
3120 dbg(0,"+#+:enter\n"); 3105
3121#endif
3122 ////DBG dbg(0,"EEnter\n"); 3106 ////DBG dbg(0,"EEnter\n");
3123 struct mapset *ms; 3107 struct mapset *ms;
3124 struct map *map; 3108 struct map *map;
3125 int callback; 3109 int callback;
3126 char *center_file; 3110 char *center_file;
3146 { 3130 {
3147 dbg(0, "no graphics\n"); 3131 dbg(0, "no graphics\n");
3148 navit_destroy(this_); 3132 navit_destroy(this_);
3149 return; 3133 return;
3150 } 3134 }
3135
3136
3137#ifdef NAVIT_FREE_TEXT_DEBUG_PRINT
3138 dbg(0, "DEST::route_clear_freetext_list(000)\n");
3139 route_clear_freetext_list();
3140#endif
3141
3151 3142
3152 //DBG dbg(0, "Connecting gui to graphics\n"); 3143 //DBG dbg(0, "Connecting gui to graphics\n");
3153 3144
3154 if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) 3145 if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra))
3155 { 3146 {
3264 // *DISABLED* navit_add_former_destinations_from_file(this_); 3255 // *DISABLED* navit_add_former_destinations_from_file(this_);
3265 } 3256 }
3266 3257
3267 if (this_->route) 3258 if (this_->route)
3268 { 3259 {
3260/*
3261*DISABLED* done in "navit_add_all_maps"
3262
3269 struct attr callback; 3263 struct attr callback;
3270 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 3264 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
3271 callback_add_names(this_->route_cb, "navit_init", "navit_redraw_route"); 3265 callback_add_names(this_->route_cb, "navit_init", "navit_redraw_route");
3272 callback.type = attr_callback; 3266 callback.type = attr_callback;
3273 callback.u.callback = this_->route_cb; 3267 callback.u.callback = this_->route_cb;
3274 route_add_attr(this_->route, &callback); 3268 route_add_attr(this_->route, &callback);
3269*/
3275 } 3270 }
3276 3271
3277 if (this_->navigation) 3272 if (this_->navigation)
3278 { 3273 {
3279 if (this_->speech) 3274 if (this_->speech)
3292 dbg(0, "Setting Center\n"); 3287 dbg(0, "Setting Center\n");
3293 center_file = bookmarks_get_center_file(FALSE); 3288 center_file = bookmarks_get_center_file(FALSE);
3294 //dbg(0, "g0\n"); 3289 //dbg(0, "g0\n");
3295 bookmarks_set_center_from_file(this_->bookmarks, center_file); 3290 bookmarks_set_center_from_file(this_->bookmarks, center_file);
3296 g_free(center_file); 3291 g_free(center_file);
3292
3293 dbg(0, "Set Vehicle Position to Center\n");
3294 navit_set_vehicle_position_to_screen_center(this_);
3297 3295
3298#if 0 3296#if 0
3299 if (this_->menubar) 3297 if (this_->menubar)
3300 { 3298 {
3301 men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL); 3299 men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL);
3348 routech_test(this_); 3346 routech_test(this_);
3349#endif 3347#endif
3350 //dbg(0, "1111111111\n"); 3348 //dbg(0, "1111111111\n");
3351} 3349}
3352 3350
3351
3352
3353// ----- forward def! -----
3354void navit_set_position_without_map_drawing(struct navit *this_, struct pcoord *c);
3355// ----- forward def! -----
3356
3357void navit_set_vehicle_position_to_screen_center_only_for_route_struct(struct navit *this_)
3358{
3359 struct coord c;
3360 char *center_file;
3361 center_file = bookmarks_get_center_file(FALSE);
3362 bookmarks_get_center_from_file(this_->bookmarks, center_file, &c);
3363 g_free(center_file);
3364
3365 struct pcoord pc;
3366 pc.x = c.x;
3367 pc.y = c.y;
3368 pc.pro = transform_get_projection(this_->trans);
3369 // result: pc.x, pc.y
3370
3371 // set position
3372 navit_set_position_without_map_drawing(this_, &pc);
3373}
3374
3375void navit_set_vehicle_position_to_screen_center(struct navit *this_)
3376{
3377
3378 // map center to pixel x,y on screen
3379 // enum projection pro = transform_get_projection(this_->trans);
3380 // struct point pnt;
3381 // struct coord *c992;
3382 // c992 = transform_get_center(this_->trans);
3383 // transform(this_->trans, pro, c992, &pnt, 1, 0, 0, NULL);
3384 // dbg(0, "navit_set_vehicle_position_to_screen_center pnt.x=%d pnt.y=%d\n", pnt.x, pnt.y);
3385 // result: pnt.x, pnt.y
3386
3387
3388 // geo to pixel-on-screen
3389 // struct coord c99;
3390 // struct coord_geo g99;
3391 // g99.lat = lat;
3392 // g99.lng = lon;
3393 // dbg(0,"zzzzz %f, %f\n",a, b);
3394 // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
3395 // transform_from_geo(projection_mg, &g99, &c99);
3396 // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
3397
3398 // enum projection pro = transform_get_projection(global_navit->trans_cursor);
3399 // struct point pnt;
3400 // transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
3401 // dbg(0,"x=%d\n",pnt.x);
3402 // dbg(0,"y=%d\n",pnt.y);
3403
3404
3405 struct coord c;
3406 char *center_file;
3407 center_file = bookmarks_get_center_file(FALSE);
3408 bookmarks_get_center_from_file(this_->bookmarks, center_file, &c);
3409 g_free(center_file);
3410
3411
3412 // coord to geo
3413 struct coord_geo g22;
3414 // struct coord c22;
3415 ////DBG // dbg(0,"%f, %f\n",a, b);
3416 ////DBG // dbg(0,"%d, %d\n",p.x, p.y);
3417 transform_to_geo(projection_mg, &c, &g22);
3418 dbg(0,"navit_set_vehicle_position_to_screen_center: %d, %d, %f, %f\n",c.x, c.y, g22.lat, g22.lng);
3419 // result = g_strdup_printf("%f:%f", g22.lat, g22.lng);
3420
3421
3422 // set vehicle position to pixel x,y
3423 //struct point p;
3424 //struct coord c;
3425
3426 // pixel-x
3427 //p.x = pnt.x;
3428 // pixel-y
3429 //p.y = pnt.y;
3430
3431 //transform_reverse(this_->trans, &p, &c);
3432
3433 struct pcoord pc;
3434 pc.x = c.x;
3435 pc.y = c.y;
3436 pc.pro = transform_get_projection(this_->trans);
3437 // result: pc.x, pc.y
3438
3439 // set position
3440 navit_set_position_without_map_drawing(this_, &pc);
3441
3442
3443 //center.pro = projection_screen;
3444 //center.x = 0;
3445 //center.y = 0;
3446 //DBG dbg(0, "veh new 5\n");
3447 // transform_setup(this_->vehicle->vehicle->trans, &pc, 16, 0);
3448 // transform_set_center(this_->vehicle->vehicle->trans, &c);
3449 // zzzzzzzzzzzzzz int vehicle_set_cursor_data_01(struct vehicle *this, struct point *pnt)
3450
3451 if ((this_) && (this_->vehicle))
3452 {
3453 this_->vehicle->coord.x = c.x;
3454 this_->vehicle->coord.y = c.y;
3455 }
3456
3457 if ((this_) && (this_->vehicle) && (this_->vehicle->vehicle))
3458 {
3459 float speed = 0;
3460 float direction = 0;
3461 double height = 0;
3462 float radius = 0;
3463 long gpstime = 0;
3464 vehicle_update_(this_->vehicle->vehicle, g22.lat, g22.lng, speed, direction, height, radius, gpstime);
3465 }
3466 else
3467 {
3468 dbg(0, "navit_set_vehicle_position_to_screen_center: no vehicle set !!\n");
3469 }
3470}
3471
3472
3473
3474
3353void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) 3475void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r)
3354{ 3476{
3355#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3356 dbg(0,"+#+:enter\n");
3357#endif
3358 ////DBG dbg(0,"EEnter\n");
3359 struct coord c; 3477 struct coord c;
3360 int scale = 16; 3478 int scale = 16;
3361 3479
3362 c.x = (r->rl.x + r->lu.x) / 2; 3480 c.x = (r->rl.x + r->lu.x) / 2;
3363 c.y = (r->rl.y + r->lu.y) / 2; 3481 c.y = (r->rl.y + r->lu.y) / 2;
3364 transform_set_center(this_->trans, &c); 3482 transform_set_center(this_->trans, &c);
3365 // dbg(1, "%x,%x-%x,%x\n", r->rl.x, r->rl.y, r->lu.x, r->lu.y); 3483
3366 while (scale < 1 << 20) 3484 while (scale < 1 << 20)
3367 { 3485 {
3368 struct point p1, p2; 3486 struct point p1, p2;
3369 transform_set_scale(this_->trans, scale); 3487 transform_set_scale(this_->trans, scale);
3370 transform_setup_source_rect(this_->trans); 3488 transform_setup_source_rect(this_->trans);
3371 transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL); 3489 transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL);
3372 transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL); 3490 transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL);
3373 // dbg(1, "%d,%d-%d,%d\n", p1.x, p1.y, p2.x, p2.y); 3491
3374 if (p1.x < 0 || p2.x < 0 || p1.x > this_->w || p2.x > this_->w || p1.y < 0 || p2.y < 0 || p1.y > this_->h || p2.y > this_->h) 3492 if (p1.x < 0 || p2.x < 0 || p1.x > this_->w || p2.x > this_->w || p1.y < 0 || p2.y < 0 || p1.y > this_->h || p2.y > this_->h)
3493 {
3375 scale *= 2; 3494 scale *= 2;
3495 }
3376 else 3496 else
3497 {
3377 break; 3498 break;
3378
3379 } 3499 }
3500 }
3501
3502 dbg(0, "scale=%d\n", scale);
3503 dbg(0, "this_->ready=%d\n", this_->ready);
3504
3380 if (this_->ready == 3) 3505 if (this_->ready == 3)
3381 { 3506 {
3382 ////DBG dbg(0,"navit_draw_async_004\n"); 3507 // dbg(0,"navit_draw_async_004\n");
3383 //dbg(0,"DO__DRAW:navit_draw_async call\n"); 3508 //dbg(0,"DO__DRAW:navit_draw_async call\n");
3384 navit_draw_async(this_, 0); 3509 navit_draw_async(this_, 0);
3385 } 3510 }
3386} 3511}
3387 3512
3388void navit_zoom_to_route(struct navit *this_, int orientation) 3513void navit_zoom_to_route(struct navit *this_, int orientation)
3389{ 3514{
3390#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3391 dbg(0,"+#+:enter\n");
3392#endif
3393 ////DBG dbg(0,"EEnter\n");
3394 struct map *map; 3515 struct map *map;
3395 struct map_rect *mr = NULL; 3516 struct map_rect *mr = NULL;
3396 struct item *item; 3517 struct item *item;
3397 struct coord c; 3518 struct coord c;
3398 struct coord_rect r; 3519 struct coord_rect r;
3399 int count = 0; 3520 int count = 0;
3521
3400 if (!this_->route) 3522 if (!this_->route)
3523 {
3401 return; 3524 return;
3402 // dbg(1, "enter\n"); 3525 }
3526
3403 map = route_get_map(this_->route); 3527 map = route_get_map(this_->route);
3404 // dbg(1, "map=%p\n", map); 3528
3405 if (map) 3529 if (map)
3530 {
3406 mr = map_rect_new(map, NULL); 3531 mr = map_rect_new(map, NULL);
3407 // dbg(1, "mr=%p\n", mr); 3532 }
3533
3408 if (mr) 3534 if (mr)
3409 { 3535 {
3410 while ((item = map_rect_get_item(mr))) 3536 while ((item = map_rect_get_item(mr)))
3411 { 3537 {
3412 // dbg(1, "item=%s\n", item_to_name(item->type));
3413 while (item_coord_get(item, &c, 1)) 3538 while (item_coord_get(item, &c, 1))
3414 { 3539 {
3415 // dbg(1, "coord\n");
3416 if (!count) 3540 if (!count)
3541 {
3417 r.lu = r.rl = c; 3542 r.lu = r.rl = c;
3543 }
3418 else 3544 else
3545 {
3419 coord_rect_extend(&r, &c); 3546 coord_rect_extend(&r, &c);
3547 }
3420 count++; 3548 count++;
3421 } 3549 }
3422 } 3550 }
3423 map_rect_destroy(mr); 3551 map_rect_destroy(mr);
3424 } 3552 }
3553
3425 if (!count) 3554 if (!count)
3555 {
3426 return; 3556 return;
3557 }
3558
3427 if (orientation != -1) 3559 if (orientation != -1)
3560 {
3428 transform_set_yaw(this_->trans, orientation); 3561 transform_set_yaw(this_->trans, orientation);
3562 }
3563
3429 navit_zoom_to_rect(this_, &r); 3564 navit_zoom_to_rect(this_, &r);
3430} 3565}
3431 3566
3432static void navit_cmd_zoom_to_route(struct navit *this) 3567static void navit_cmd_zoom_to_route(struct navit *this)
3433{ 3568{
3434#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3569
3435 dbg(0,"+#+:enter\n"); 3570
3436#endif
3437 ////DBG dbg(0,"EEnter\n"); 3571 ////DBG dbg(0,"EEnter\n");
3438 navit_zoom_to_route(this, 0); 3572 navit_zoom_to_route(this, 0);
3439} 3573}
3440 3574
3441/** 3575/**
3445 * @param center The point where to center the map, including its projection 3579 * @param center The point where to center the map, including its projection
3446 * @returns nothing 3580 * @returns nothing
3447 */ 3581 */
3448void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout) 3582void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout)
3449{ 3583{
3450#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3584
3451 dbg(0,"+#+:enter\n"); 3585
3452#endif
3453 ////DBG dbg(0,"EEnter\n"); 3586 ////DBG dbg(0,"EEnter\n");
3454 struct coord *c = transform_center(this_->trans); 3587 struct coord *c = transform_center(this_->trans);
3455 struct coord c1, c2; 3588 struct coord c1, c2;
3456 enum projection pro = transform_get_projection(this_->trans); 3589 enum projection pro = transform_get_projection(this_->trans);
3457 3590
3479 } 3612 }
3480} 3613}
3481 3614
3482static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) 3615static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout)
3483{ 3616{
3484#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3617
3485 dbg(0,"+#+:enter\n"); 3618
3486#endif
3487 ////DBG dbg(0,"EEnter\n"); 3619 ////DBG dbg(0,"EEnter\n");
3488 int width, height; 3620 int width, height;
3489 struct point po; 3621 struct point po;
3490 transform_set_center(this_->trans, c); 3622 transform_set_center(this_->trans, c);
3491 transform_get_size(this_->trans, &width, &height); 3623 transform_get_size(this_->trans, &width, &height);
3504 * @param this_ A navit instance 3636 * @param this_ A navit instance
3505 * @author Ralph Sennhauser (10/2009) 3637 * @author Ralph Sennhauser (10/2009)
3506 */ 3638 */
3507void navit_set_cursors(struct navit *this_) 3639void navit_set_cursors(struct navit *this_)
3508{ 3640{
3509#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3641
3510 dbg(0,"+#+:enter\n"); 3642
3511#endif
3512 struct attr name; 3643 struct attr name;
3513 struct navit_vehicle *nv; 3644 struct navit_vehicle *nv;
3514 struct cursor *c; 3645 struct cursor *c;
3515 GList *v; 3646 GList *v;
3516 3647
3542 return; 3673 return;
3543} 3674}
3544 3675
3545void navit_remove_cursors(struct navit *this_) 3676void navit_remove_cursors(struct navit *this_)
3546{ 3677{
3547#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3678
3548 dbg(0,"+#+:enter\n"); 3679
3549#endif
3550 struct attr name; 3680 struct attr name;
3551 struct navit_vehicle *nv; 3681 struct navit_vehicle *nv;
3552 struct cursor *c; 3682 struct cursor *c;
3553 GList *v; 3683 GList *v;
3554 3684
3566 return; 3696 return;
3567} 3697}
3568 3698
3569static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) 3699static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir)
3570{ 3700{
3571#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3701
3572 dbg(0,"+#+:enter\n"); 3702
3573#endif
3574 ////DBG dbg(0,"EEnter\n"); 3703 ////DBG dbg(0,"EEnter\n");
3575 int width, height; 3704 int width, height;
3576 struct navit_vehicle *nv = this_->vehicle; 3705 struct navit_vehicle *nv = this_->vehicle;
3577 3706
3578 float offset = this_->radius; // Cursor offset from the center of the screen (percent). 3707 float offset = this_->radius; // Cursor offset from the center of the screen (percent).
3610 { 3739 {
3611 int mdir; 3740 int mdir;
3612 if (this_->tracking && this_->tracking_flag) 3741 if (this_->tracking && this_->tracking_flag)
3613 { 3742 {
3614 mdir = tracking_get_angle(this_->tracking) - this_->orientation; 3743 mdir = tracking_get_angle(this_->tracking) - this_->orientation;
3744 dbg(0, "+++++tr angle=%d\n", tracking_get_angle(this_->tracking));
3745 dbg(0, "+++++this ori=%d\n", this_->orientation);
3615 } 3746 }
3616 else 3747 else
3617 { 3748 {
3618 mdir = nv->dir - this_->orientation; 3749 mdir = nv->dir - this_->orientation;
3619 } 3750 }
3628 return 1; 3759 return 1;
3629} 3760}
3630 3761
3631void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) 3762void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation)
3632{ 3763{
3633#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3764
3634 dbg(0,"+#+:enter\n"); 3765
3635#endif
3636 ////DBG dbg(0,"EEnter\n"); 3766 ////DBG dbg(0,"EEnter\n");
3637 int dir; 3767 int dir;
3638 struct point pn; 3768 struct point pn;
3639 struct navit_vehicle *nv = this_->vehicle; 3769 struct navit_vehicle *nv = this_->vehicle;
3640 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); 3770 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
3643 // OLD // navit_autozoom(this_, &nv->coord, nv->speed, 0); 3773 // OLD // navit_autozoom(this_, &nv->coord, nv->speed, 0);
3644} 3774}
3645 3775
3646static void navit_set_center_cursor_draw(struct navit *this_) 3776static void navit_set_center_cursor_draw(struct navit *this_)
3647{ 3777{
3648#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3778
3649 dbg(0,"+#+:enter\n"); 3779
3650#endif
3651 //dbg(0,"EEnter\n"); 3780 //dbg(0,"EEnter\n");
3652 navit_set_center_cursor(this_, 1, 0); 3781 navit_set_center_cursor(this_, 1, 0);
3653 if (this_->ready == 3) 3782 if (this_->ready == 3)
3654 { 3783 {
3655 //dbg(0,"navit_draw_async_005\n"); 3784 // dbg(0,"navit_draw_async_005\n");
3656 //dbg(0,"DO__DRAW:navit_draw_async call (AS)\n"); 3785 //dbg(0,"DO__DRAW:navit_draw_async call (AS)\n");
3657 navit_draw_async(this_, 1); 3786 // zzz554 // navit_draw_async(this_, 1);
3658 } 3787 }
3659} 3788}
3660 3789
3661static void navit_cmd_set_center_cursor(struct navit *this_) 3790static void navit_cmd_set_center_cursor(struct navit *this_)
3662{ 3791{
3663#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3792
3664 dbg(0,"+#+:enter\n"); 3793
3665#endif
3666 ////DBG dbg(0,"EEnter\n"); 3794 ////DBG dbg(0,"EEnter\n");
3667 navit_set_center_cursor_draw(this_); 3795 navit_set_center_cursor_draw(this_);
3668} 3796}
3669 3797
3670void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout) 3798void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout)
3671{ 3799{
3672#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3800
3673 dbg(0,"+#+:enter\n"); 3801
3674#endif
3675 ////DBG dbg(0,"EEnter\n"); 3802 ////DBG dbg(0,"EEnter\n");
3676 struct coord c; 3803 struct coord c;
3677 struct pcoord pc; 3804 struct pcoord pc;
3678 transform_reverse(this_->trans, p, &c); 3805 transform_reverse(this_->trans, p, &c);
3679 pc.x = c.x; 3806 pc.x = c.x;
3693 break; 3820 break;
3694#endif 3821#endif
3695 3822
3696static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) 3823static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init)
3697{ 3824{
3698#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3825
3699 dbg(0,"+#+:enter\n");
3700#endif
3701 ////DBG dbg(0,"EEnter\n");
3702 int dir = 0, orient_old = 0, attr_updated = 0; 3826 int dir = 0, orient_old = 0, attr_updated = 0;
3703 struct coord co; 3827 struct coord co;
3704 long zoom; 3828 long zoom;
3705 GList *l; 3829 GList *l;
3706 struct navit_vehicle *nv; 3830 struct navit_vehicle *nv;
3840 attr_updated = (this_->center_timeout != attr->u.num); 3964 attr_updated = (this_->center_timeout != attr->u.num);
3841 this_->center_timeout = attr->u.num; 3965 this_->center_timeout = attr->u.num;
3842 break; 3966 break;
3843 case attr_tracking: 3967 case attr_tracking:
3844 attr_updated = (this_->tracking_flag != !!attr->u.num); 3968 attr_updated = (this_->tracking_flag != !!attr->u.num);
3969 // dbg(0, "set attr:attr_tracking old=%d\n", this_->tracking_flag);
3845 this_->tracking_flag = !!attr->u.num; 3970 this_->tracking_flag = !!attr->u.num;
3971 // dbg(0, "set attr:attr_tracking new=%d\n", this_->tracking_flag);
3846 break; 3972 break;
3847 case attr_transformation: 3973 case attr_transformation:
3848 this_->trans = attr->u.transformation; 3974 this_->trans = attr->u.transformation;
3849 break; 3975 break;
3850 case attr_use_mousewheel: 3976 case attr_use_mousewheel:
3900 this_->imperial = attr->u.num; 4026 this_->imperial = attr->u.num;
3901 break; 4027 break;
3902 default: 4028 default:
3903 return 0; 4029 return 0;
3904 } 4030 }
4031
3905 if (attr_updated && !init) 4032 if (attr_updated && !init)
3906 { 4033 {
4034 // dbg(0, "set attr:call callback_list_call_attr_2\n");
3907 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); 4035 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
4036
3908 if (attr->type == attr_osd_configuration) 4037 if (attr->type == attr_osd_configuration)
3909 { 4038 {
3910 graphics_draw_mode(this_->gra, draw_mode_end); 4039 graphics_draw_mode(this_->gra, draw_mode_end);
3911 } 4040 }
3912 } 4041 }
3913 4042
3914#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3915 dbg(0,"+#+:leave\n");
3916#endif
3917
3918 return 1; 4043 return 1;
3919} 4044}
3920 4045
3921int navit_set_attr(struct navit *this_, struct attr *attr) 4046int navit_set_attr(struct navit *this_, struct attr *attr)
3922{ 4047{
3923#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3924 dbg(0,"+#+:enter\n");
3925#endif
3926 ////DBG dbg(0,"EEnter\n");
3927 return navit_set_attr_do(this_, attr, 0); 4048 return navit_set_attr_do(this_, attr, 0);
3928} 4049}
3929 4050
3930int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) 4051int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
3931{ 4052{
3932#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4053
3933 dbg(0,"+#+:enter\n");
3934#endif
3935 ////DBG dbg(0,"EEnter\n");
3936 struct message *msg; 4054 struct message *msg;
3937 int len, offset; 4055 int len, offset;
3938 int ret = 1; 4056 int ret = 1;
3939 4057
3940 switch (type) 4058 switch (type)
4132 default: 4250 default:
4133 return 0; 4251 return 0;
4134 } 4252 }
4135 attr->type = type; 4253 attr->type = type;
4136 4254
4137#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4138 dbg(0,"+#+:leave\n");
4139#endif
4140
4141 return ret; 4255 return ret;
4142} 4256}
4143 4257
4144void displaylist_shift_order_in_map_layers(struct navit *this_, int shift_value) 4258void displaylist_shift_order_in_map_layers(struct navit *this_, int shift_value)
4145{ 4259{
4146#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4260
4147 dbg(0,"+#+:enter\n"); 4261
4148#endif
4149 4262
4150 GList *l; 4263 GList *l;
4151 struct layout *lay; 4264 struct layout *lay;
4152 GList *l2; 4265 GList *l2;
4153 struct layer *layer; 4266 struct layer *layer;
4294#endif 4407#endif
4295} 4408}
4296 4409
4297void displaylist_shift_for_dpi_value_in_layers(struct navit *this_, double factor) 4410void displaylist_shift_for_dpi_value_in_layers(struct navit *this_, double factor)
4298{ 4411{
4299#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4412
4300 dbg(0,"+#+:enter\n"); 4413
4301#endif
4302 4414
4303 GList *l; 4415 GList *l;
4304 struct layout *lay; 4416 struct layout *lay;
4305 GList *l2; 4417 GList *l2;
4306 struct layer *layer; 4418 struct layer *layer;
4410} 4522}
4411 4523
4412 4524
4413static int navit_add_log(struct navit *this_, struct log *log) 4525static int navit_add_log(struct navit *this_, struct log *log)
4414{ 4526{
4415#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4527
4416 dbg(0,"+#+:enter\n"); 4528
4417#endif
4418 struct attr type_attr; 4529 struct attr type_attr;
4419 if (!log_get_attr(log, attr_type, &type_attr, NULL)) 4530 if (!log_get_attr(log, attr_type, &type_attr, NULL))
4420 return 0; 4531 return 0;
4421 if (!strcmp(type_attr.u.str, "textfile_debug")) 4532 if (!strcmp(type_attr.u.str, "textfile_debug"))
4422 { 4533 {
4430 return 0; 4541 return 0;
4431} 4542}
4432 4543
4433static int navit_add_layout(struct navit *this_, struct layout *layout) 4544static int navit_add_layout(struct navit *this_, struct layout *layout)
4434{ 4545{
4435#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4546
4436 dbg(0,"+#+:enter\n"); 4547
4437#endif
4438 ////DBG dbg(0,"EEnter\n"); 4548 ////DBG dbg(0,"EEnter\n");
4439 struct attr active; 4549 struct attr active;
4440 this_->layouts = g_list_append(this_->layouts, layout); 4550 this_->layouts = g_list_append(this_->layouts, layout);
4441 layout_get_attr(layout, attr_active, &active, NULL); 4551 layout_get_attr(layout, attr_active, &active, NULL);
4442 if (active.u.num || !this_->layout_current) 4552 if (active.u.num || !this_->layout_current)
4447 return 0; 4557 return 0;
4448} 4558}
4449 4559
4450int navit_add_attr(struct navit *this_, struct attr *attr) 4560int navit_add_attr(struct navit *this_, struct attr *attr)
4451{ 4561{
4452#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4562
4453 dbg(0,"+#+:enter\n"); 4563
4454#endif
4455 ////DBG dbg(0,"EEnter\n"); 4564 ////DBG dbg(0,"EEnter\n");
4456 4565
4457 int ret = 1; 4566 int ret = 1;
4458 switch (attr->type) 4567 switch (attr->type)
4459 { 4568 {
4511 return ret; 4620 return ret;
4512} 4621}
4513 4622
4514int navit_remove_attr(struct navit *this_, struct attr *attr) 4623int navit_remove_attr(struct navit *this_, struct attr *attr)
4515{ 4624{
4516#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4625
4517 dbg(0,"+#+:enter\n"); 4626
4518#endif
4519 int ret = 1; 4627 int ret = 1;
4520 switch (attr->type) 4628 switch (attr->type)
4521 { 4629 {
4522 case attr_callback: 4630 case attr_callback:
4523 navit_remove_callback(this_, attr->u.callback); 4631 navit_remove_callback(this_, attr->u.callback);
4534} 4642}
4535 4643
4536struct attr_iter * 4644struct attr_iter *
4537navit_attr_iter_new(void) 4645navit_attr_iter_new(void)
4538{ 4646{
4539#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4647
4540 dbg(0,"+#+:enter\n"); 4648
4541#endif
4542return g_new0(struct attr_iter, 1); 4649return g_new0(struct attr_iter, 1);
4543} 4650}
4544 4651
4545void navit_attr_iter_destroy(struct attr_iter *iter) 4652void navit_attr_iter_destroy(struct attr_iter *iter)
4546{ 4653{
4547#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4654
4548 dbg(0,"+#+:enter\n"); 4655
4549#endif
4550 g_free(iter); 4656 g_free(iter);
4551} 4657}
4552 4658
4553void navit_add_callback(struct navit *this_, struct callback *cb) 4659void navit_add_callback(struct navit *this_, struct callback *cb)
4554{ 4660{
4555#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4661
4556 dbg(0,"+#+:enter\n"); 4662
4557#endif
4558 ////DBG dbg(0,"EEnter\n"); 4663 ////DBG dbg(0,"EEnter\n");
4559 4664
4560 callback_list_add(this_->attr_cbl, cb); 4665 callback_list_add(this_->attr_cbl, cb);
4561} 4666}
4562 4667
4563void navit_remove_callback(struct navit *this_, struct callback *cb) 4668void navit_remove_callback(struct navit *this_, struct callback *cb)
4564{ 4669{
4565#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4670
4566 dbg(0,"+#+:enter\n"); 4671
4567#endif
4568 ////DBG dbg(0,"EEnter\n"); 4672 ////DBG dbg(0,"EEnter\n");
4569 4673
4570 callback_list_remove(this_->attr_cbl, cb); 4674 callback_list_remove(this_->attr_cbl, cb);
4571} 4675}
4572 4676
4576 * @param navit The navit instance 4680 * @param navit The navit instance
4577 * @returns nothing 4681 * @returns nothing
4578 */ 4682 */
4579static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt) 4683static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt)
4580{ 4684{
4581#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4685__F_START__
4582 dbg(0,"+#+:enter\n");
4583#endif
4584 ////DBG dbg(0,"EEnter\n");
4585 4686
4586 struct point cursor_pnt; 4687 struct point cursor_pnt;
4587 enum projection pro; 4688 enum projection pro;
4588 4689
4589 if (this_->blocked) 4690 if (this_->blocked)
4590 { 4691 {
4591 return; 4692 return2;
4592 } 4693 }
4593 4694
4594 if (pnt) 4695 if (pnt)
4595 { 4696 {
4596 cursor_pnt = *pnt; 4697 cursor_pnt = *pnt;
4598 else 4699 else
4599 { 4700 {
4600 pro = transform_get_projection(this_->trans_cursor); 4701 pro = transform_get_projection(this_->trans_cursor);
4601 if (!pro) 4702 if (!pro)
4602 { 4703 {
4603 return; 4704 return2;
4604 } 4705 }
4605 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 4706 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
4606 } 4707 }
4607 4708
4608 //dbg(0,"xx=%d\n",cursor_pnt.x); 4709 //dbg(0,"xx=%d\n",cursor_pnt.x);
4627 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, pnt == NULL); 4728 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, pnt == NULL);
4628#else 4729#else
4629 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1); 4730 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1);
4630#endif 4731#endif
4631#endif 4732#endif
4733
4734__F_END__
4632} 4735}
4633 4736
4634 4737
4635 4738
4636// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4739// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4637// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4740// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4638// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4741// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4639static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) 4742static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
4640{ 4743{
4744
4745__F_START__
4746
4641#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4747#ifdef NAVIT_ROUTING_DEBUG_PRINT
4642 dbg(0,"+#+:enter\n"); 4748 dbg(0, "\n");
4749 dbg(0, "==================================================================================\n");
4750 dbg(0, "==================================================================================\n");
4751 dbg(0, "\n");
4752#endif
4753
4754
4755#ifdef NAVIT_ROUTING_DEBUG_PRINT
4756 dbg(0, "ROUTExxPOSxx:navit_vehicle_update:enter\n");
4643#endif 4757#endif
4644 4758
4645#ifdef NAVIT_MEASURE_TIME_DEBUG 4759#ifdef NAVIT_MEASURE_TIME_DEBUG
4646 clock_t s_ = debug_measure_start(); 4760 clock_t s_ = debug_measure_start();
4647#endif 4761#endif
4665 long old_scale_value; 4779 long old_scale_value;
4666 4780
4667 if (this_->ready != 3) 4781 if (this_->ready != 3)
4668 { 4782 {
4669 //profile(0,"return 1\n"); 4783 //profile(0,"return 1\n");
4784#ifdef NAVIT_ROUTING_DEBUG_PRINT
4785 dbg(0, "ROUTExxPOSxx:return 003\n");
4786#endif
4787
4788
4789#ifdef NAVIT_ROUTING_DEBUG_PRINT
4790 dbg(0, "\n");
4791 dbg(0, "==================================================================================\n");
4792 dbg(0, "==================================================================================\n");
4793 dbg(0, "\n");
4794#endif
4795
4670 return; 4796 return2;
4671 } 4797 }
4672 4798
4673 navit_layout_switch(this_); 4799 // **OLD** navit_layout_switch(this_);
4674 if (this_->vehicle == nv && this_->tracking_flag) 4800 if (this_->vehicle == nv && this_->tracking_flag)
4675 { 4801 {
4676 tracking = this_->tracking; 4802 tracking = this_->tracking;
4677 } 4803 }
4804 //// else tracking = NULL !! -> important for next "if" clause!!
4805
4806 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4807 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4808 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4809 struct attr attr_pos_unchanged;
4810 if (vehicle_get_attr(nv->vehicle, attr_position_coord_geo, &attr_pos_unchanged, NULL))
4811 {
4812 if (attr_pos_unchanged.u.coord_geo)
4813 {
4814 global_v_pos_lat = attr_pos_unchanged.u.coord_geo->lat;
4815 global_v_pos_lng = attr_pos_unchanged.u.coord_geo->lng;
4816
4817#ifdef NAVIT_ROUTING_DEBUG_PRINT
4818 struct coord cc999;
4819 transform_from_geo(pro, attr_pos_unchanged.u.coord_geo, &cc999);
4820 dbg(0, "ROUTExxPOSxx:navit_vehicle_update: %d %d\n", cc999.x, cc999.y);
4821#endif
4822
4823 }
4824 }
4825
4826 if (vehicle_get_attr(nv->vehicle, attr_position_direction, &attr_pos_unchanged, NULL))
4827 {
4828 global_v_pos_dir = *attr_pos_unchanged.u.numd;
4829
4830#ifdef NAVIT_ROUTING_DEBUG_PRINT
4831 dbg(0, "ROUTExxPOSxx:navit_vehicle_update: dir=%f\n", (float)global_v_pos_dir);
4832#endif
4833 }
4834 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4835 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4836 // ------ DEBUG ------ remember real GPS postion (unchanged) -------
4837
4678 4838
4679 if (tracking) 4839 if (tracking)
4680 { 4840 {
4841#ifdef NAVIT_ROUTING_DEBUG_PRINT
4842 dbg(0, "ROUTExxPOSxx:tracking_update: 001\n");
4843#endif
4844
4845 // set postition from tracking (changing it to nearest street)
4681 tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro); 4846 tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro);
4682 attr_object = tracking; 4847 attr_object = tracking;
4683 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) tracking_get_attr; 4848 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) tracking_get_attr;
4849
4850#ifdef NAVIT_ROUTING_DEBUG_PRINT
4851 dbg(0, "ROUTExxPOSxx:tracking_update: 001-a\n");
4852#endif
4684 } 4853 }
4685 else 4854 else
4686 { 4855 {
4856#ifdef NAVIT_ROUTING_DEBUG_PRINT
4857 dbg(0, "ROUTExxPOSxx:tracking_update (unchanged): 001.bb\n");
4858#endif
4859
4860 // set position from vehicle (unchanged)
4687 attr_object = nv->vehicle; 4861 attr_object = nv->vehicle;
4688 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) vehicle_get_attr; 4862 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) vehicle_get_attr;
4863
4864#ifdef NAVIT_ROUTING_DEBUG_PRINT
4865 dbg(0, "ROUTExxPOSxx:tracking_update (unchanged): 001.bb-a\n");
4866#endif
4689 } 4867 }
4690 4868
4691 if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL)) 4869 if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL))
4692 { 4870 {
4693 if (!attr_valid.u.num != attr_position_valid_invalid) 4871 if (!attr_valid.u.num != attr_position_valid_invalid)
4694 { 4872 {
4873#ifdef NAVIT_ROUTING_DEBUG_PRINT
4874 dbg(0, "ROUTExxPOSxx:return 001\n");
4875#endif
4876
4877#ifdef NAVIT_ROUTING_DEBUG_PRINT
4878 dbg(0, "\n");
4879 dbg(0, "==================================================================================\n");
4880 dbg(0, "==================================================================================\n");
4881 dbg(0, "\n");
4882#endif
4883
4695 return; 4884 return2;
4696 }
4697 } 4885 }
4886 }
4887
4888
4889#ifdef NAVIT_ROUTING_DEBUG_PRINT
4890 struct attr attr_pos_99;
4891 if (get_attr(attr_object, attr_position_coord_geo, &attr_pos_99, NULL))
4892 {
4893 if (attr_pos_99.u.coord_geo)
4894 {
4895 struct coord cc999;
4896 transform_from_geo(pro, attr_pos_99.u.coord_geo, &cc999);
4897 dbg(0, "ROUTExxPOSxx:get pos: %d %d\n", cc999.x, cc999.y);
4898 }
4899 }
4900#endif
4901
4698 4902
4699 // load attrs with data from vehicle 4903 // load attrs with data from vehicle
4700 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)) 4904 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))
4701 { 4905 {
4906#ifdef NAVIT_ROUTING_DEBUG_PRINT
4907 dbg(0, "ROUTExxPOSxx:return 002\n");
4908#endif
4909
4910#ifdef NAVIT_ROUTING_DEBUG_PRINT
4911 dbg(0, "\n");
4912 dbg(0, "==================================================================================\n");
4913 dbg(0, "==================================================================================\n");
4914 dbg(0, "\n");
4915#endif
4916
4702 return; 4917 return2;
4703 } 4918 }
4704 // load attrs with data from vehicle 4919 // load attrs with data from vehicle
4705 4920
4706 4921
4707 // save old value 4922 // save old value
4751 4966
4752 if (this_->route) 4967 if (this_->route)
4753 { 4968 {
4754 if (tracking) 4969 if (tracking)
4755 { 4970 {
4971#ifdef NAVIT_ROUTING_DEBUG_PRINT
4972 dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 001\n");
4973#endif
4756 route_set_position_from_tracking(this_->route, tracking, pro); 4974 route_set_position_from_tracking(this_->route, tracking, pro);
4975#ifdef NAVIT_ROUTING_DEBUG_PRINT
4976 dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 001-a\n");
4977#endif
4757 } 4978 }
4758 else 4979 else
4759 { 4980 {
4981#ifdef NAVIT_ROUTING_DEBUG_PRINT
4982 dbg(0, "ROUTExxPOSxx:YYYYY:navit_vehicle_update: 002\n");
4983#endif
4760 route_set_position(this_->route, &cursor_pc); 4984 route_set_position(this_->route, &cursor_pc);
4761 } 4985#ifdef NAVIT_ROUTING_DEBUG_PRINT
4986 dbg(0, "ROUTExxPOSxx:navit_vehicle_update: 002-a\n");
4987#endif
4762 } 4988 }
4989 }
4763 4990
4764 callback_list_call_attr_0(this_->attr_cbl, attr_position); 4991 // --------------------------------------------------------------
4992 // --------------------------------------------------------------
4993 // this calls: graphics_load_mapset (and draws the map)
4994 // --------------------------------------------------------------
4995 /// -------**++**-- DISABLE --**++**---- callback_list_call_attr_0(this_->attr_cbl, attr_position);
4996 // --------------------------------------------------------------
4997 // --------------------------------------------------------------
4765 4998
4766 // navit_textfile_debug_log(this_, "type=trackpoint_tracked"); 4999 // navit_textfile_debug_log(this_, "type=trackpoint_tracked");
4767 /* 5000 /*
4768 if (this_->gui && nv->speed > MYSTERY_SPEED) 5001 if (this_->gui && nv->speed > MYSTERY_SPEED)
4769 { 5002 {
4796 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle); 5029 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle);
4797 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom); 5030 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom);
4798#endif 5031#endif
4799 } 5032 }
4800 5033
5034
5035
5036// -------- ??????????
5037// -------- ??????????
5038// -------- ??????????
5039// -------- ??????????
5040// -------- ??????????
4801 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))) 5041 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)))
4802 { 5042 {
4803 if (hold_drawing == 0) 5043 if (hold_drawing == 0)
4804 { 5044 {
4805 //dbg(0,"call:navit_set_center_cursor_draw:start\n"); 5045 //dbg(0,"call:navit_set_center_cursor_draw:start\n");
4812 if (hold_drawing == 0) 5052 if (hold_drawing == 0)
4813 { 5053 {
4814 navit_vehicle_draw(this_, nv, pnt); 5054 navit_vehicle_draw(this_, nv, pnt);
4815 } 5055 }
4816 } 5056 }
5057// -------- ??????????
5058// -------- ??????????
5059// -------- ??????????
5060// -------- ??????????
5061// -------- ??????????
5062
5063
5064
4817 5065
4818 if (nv->follow_curr > 1) 5066 if (nv->follow_curr > 1)
4819 { 5067 {
4820 nv->follow_curr--; 5068 nv->follow_curr--;
4821 } 5069 }
4822 else 5070 else
4823 { 5071 {
4824 nv->follow_curr = nv->follow; 5072 nv->follow_curr = nv->follow;
4825 } 5073 }
4826 5074
5075
5076
5077 // where does this go????? ----------
5078 // where does this go????? ----------
4827 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle); 5079 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle);
5080 // where does this go????? ----------
5081 // where does this go????? ----------
5082
5083
4828 5084
4829 /* Finally, if we reached our destination, stop navigation. */ 5085 /* Finally, if we reached our destination, stop navigation. */
4830 if (this_->route) 5086 if (this_->route)
4831 { 5087 {
4832 switch (route_destination_reached(this_->route)) 5088 switch (route_destination_reached(this_->route))
4868 // draw??????? 5124 // draw???????
4869 // navit_draw(this_); 5125 // navit_draw(this_);
4870 if (this_->ready == 3) 5126 if (this_->ready == 3)
4871 { 5127 {
4872 //dbg(0,"location update:draw:start\n"); 5128 //dbg(0,"location update:draw:start\n");
5129 // dbg(0,"navit_draw_async_006\n");
5130 // zzz554 //
4873 //navit_draw_async(this_, 1); 5131 navit_draw_async(this_, 0);
4874 //dbg(0,"location update:draw:end\n"); 5132 //dbg(0,"location update:draw:end\n");
4875 } 5133 }
4876 // draw??????? 5134 // draw???????
4877 } 5135 }
4878 5136
4879#ifdef NAVIT_MEASURE_TIME_DEBUG 5137#ifdef NAVIT_MEASURE_TIME_DEBUG
4880 debug_mrp("navit_vehicle_update:", debug_measure_end(s_)); 5138 debug_mrp("navit_vehicle_update:", debug_measure_end(s_));
4881#endif 5139#endif
4882 5140
4883#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5141#ifdef NAVIT_ROUTING_DEBUG_PRINT
4884 dbg(0,"+#+:leave\n"); 5142 dbg(0, "ROUTExxPOSxx:navit_vehicle_update:leave\n");
4885#endif 5143#endif
5144
5145#ifdef NAVIT_ROUTING_DEBUG_PRINT
5146 dbg(0, "\n");
5147 dbg(0, "==================================================================================\n");
5148 dbg(0, "==================================================================================\n");
5149 dbg(0, "\n");
5150#endif
5151
5152__F_END__
5153
4886} 5154}
4887// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 5155// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4888// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 5156// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4889// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 5157// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4890 5158
4891 5159
5160
5161int navit_is_demo_vehicle()
5162{
5163 if (global_demo_vehicle == 1)
5164 {
5165 return 1;
5166 }
5167
5168 return 0;
5169}
4892 5170
4893 5171
4894/** 5172/**
4895 * Set the position of the vehicle 5173 * Set the position of the vehicle
4896 * 5174 *
4898 * @param c The coordinate to set as position 5176 * @param c The coordinate to set as position
4899 * @returns nothing 5177 * @returns nothing
4900 */ 5178 */
4901void navit_set_position(struct navit *this_, struct pcoord *c) 5179void navit_set_position(struct navit *this_, struct pcoord *c)
4902{ 5180{
5181__F_START__
5182
5183 //DBG dbg(0,"EEnter\n");
5184
5185 if (this_->route)
5186 {
5187//#ifdef NAVIT_ROUTING_DEBUG_PRINT
5188// dbg(0, "ROUTExxPOSxx:YYYYY:navit_set_position: 001\n");
5189//#endif
5190 // ******* NOT USE ******** // route_set_position(this_->route, c);
5191 // ******* NOT USE ******** // callback_list_call_attr_0(this_->attr_cbl, attr_position);
5192 }
5193
5194 if (this_->ready == 3)
5195 {
5196 navit_draw(this_);
5197 }
5198
5199__F_END__
5200}
5201
5202/**
5203 * Set the position of the vehicle, without drawing the map
5204 *
5205 */
5206void navit_set_position_without_map_drawing(struct navit *this_, struct pcoord *c)
5207{
5208
5209
5210
5211 if (this_->route)
5212 {
4903#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5213#ifdef NAVIT_ROUTING_DEBUG_PRINT
4904 dbg(0,"+#+:enter\n"); 5214 dbg(0, "ROUTExxPOSxx:YYYYY:navit_set_position_without_map_drawing: 001\n");
4905#endif 5215#endif
4906 //DBG dbg(0,"EEnter\n");
4907
4908 if (this_->route)
4909 {
4910 route_set_position(this_->route, c); 5216 route_set_position(this_->route, c);
4911 callback_list_call_attr_0(this_->attr_cbl, attr_position); 5217 callback_list_call_attr_0(this_->attr_cbl, attr_position);
4912 } 5218 }
4913
4914 if (this_->ready == 3)
4915 {
4916 navit_draw(this_);
4917 }
4918} 5219}
4919 5220
5221
4920static int navit_set_vehicleprofile(struct navit *this_, char *name) 5222int navit_set_vehicleprofile(struct navit *this_, char *name)
4921{ 5223{
4922#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5224
4923 dbg(0,"+#+:enter\n"); 5225
4924#endif
4925 ////DBG dbg(0,"EEnter\n"); 5226 ////DBG dbg(0,"EEnter\n");
4926 5227
4927 struct attr attr; 5228 struct attr attr;
4928 GList *l; 5229 GList *l;
4929 l = this_->vehicleprofiles; 5230 l = this_->vehicleprofiles;
4933 { 5234 {
4934 if (!strcmp(attr.u.str, name)) 5235 if (!strcmp(attr.u.str, name))
4935 { 5236 {
4936 this_->vehicleprofile = l->data; 5237 this_->vehicleprofile = l->data;
4937 if (this_->route) 5238 if (this_->route)
5239 {
4938 route_set_profile(this_->route, this_->vehicleprofile); 5240 route_set_profile(this_->route, this_->vehicleprofile);
5241 }
4939 return 1; 5242 return 1;
4940 } 5243 }
4941 } 5244 }
4942 l = g_list_next(l); 5245 l = g_list_next(l);
4943 } 5246 }
4944 return 0; 5247 return 0;
4945} 5248}
4946 5249
4947static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv) 5250static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv)
4948{ 5251{
4949#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5252
4950 dbg(0,"+#+:enter\n"); 5253
4951#endif
4952 ////DBG dbg(0,"EEnter\n"); 5254 ////DBG dbg(0,"EEnter\n");
4953 5255
4954 struct attr attr; 5256 struct attr attr;
4955 this_->vehicle = nv; 5257 this_->vehicle = nv;
4956 5258
4986 * @param v The vehicle instance 5288 * @param v The vehicle instance
4987 * @returns 1 for success 5289 * @returns 1 for success
4988 */ 5290 */
4989int navit_add_vehicle(struct navit *this_, struct vehicle *v) 5291int navit_add_vehicle(struct navit *this_, struct vehicle *v)
4990{ 5292{
4991#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5293
4992 dbg(0,"+#+:enter\n"); 5294
4993#endif
4994 5295
4995 struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1); 5296 struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
4996 struct attr follow, active, animate; 5297 struct attr follow, active, animate;
4997 nv->vehicle = v; 5298 nv->vehicle = v;
4998 nv->follow = 0; 5299 nv->follow = 0;
5000 nv->last.y = 0; 5301 nv->last.y = 0;
5001 5302
5002 global_last_vehicle_pos_geo.lat = 0; 5303 global_last_vehicle_pos_geo.lat = 0;
5003 global_last_vehicle_pos_geo.lng = 0; 5304 global_last_vehicle_pos_geo.lng = 0;
5004 5305
5306 // global_cur_vehicle_pos_geo.lat = 0;
5307 // global_cur_vehicle_pos_geo.lon = 0;
5308
5005 nv->animate_cursor = 0; 5309 nv->animate_cursor = 0;
5006 if ((vehicle_get_attr(v, attr_follow, &follow, NULL))) 5310 if ((vehicle_get_attr(v, attr_follow, &follow, NULL)))
5007 nv->follow = follow.u.num; 5311 nv->follow = follow.u.num;
5312
5008 nv->follow_curr = nv->follow; 5313 nv->follow_curr = nv->follow;
5009 this_->vehicles = g_list_append(this_->vehicles, nv); 5314 this_->vehicles = g_list_append(this_->vehicles, nv);
5315
5010 if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num) 5316 if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num)
5011 navit_set_vehicle(this_, nv); 5317 navit_set_vehicle(this_, nv);
5318
5012 if ((vehicle_get_attr(v, attr_animate, &animate, NULL))) 5319 if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
5013 nv->animate_cursor = animate.u.num; 5320 nv->animate_cursor = animate.u.num;
5321
5014 nv->callback.type = attr_callback; 5322 nv->callback.type = attr_callback;
5015 5323
5016 // gets called via this callback in vehicle_android.c [in function: vehicle_android_callback] 5324 // gets called via this callback in vehicle_android.c [in function: vehicle_android_callback]
5017 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv); 5325 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv);
5018 callback_add_names(nv->callback.u.callback, "navit_add_vehicle", "navit_vehicle_update"); 5326 callback_add_names(nv->callback.u.callback, "navit_add_vehicle", "navit_vehicle_update");
5031} 5339}
5032 5340
5033struct gui * 5341struct gui *
5034navit_get_gui(struct navit *this_) 5342navit_get_gui(struct navit *this_)
5035{ 5343{
5036#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5037 dbg(0,"+#+:enter\n");
5038#endif
5039 return this_->gui; 5344 return this_->gui;
5040} 5345}
5041 5346
5042struct transformation * 5347struct transformation *
5043navit_get_trans(struct navit *this_) 5348navit_get_trans(struct navit *this_)
5044{ 5349{
5045#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5046 dbg(0,"+#+:enter\n");
5047#endif
5048 return this_->trans; 5350 return this_->trans;
5049} 5351}
5050 5352
5051struct route * 5353struct route *
5052navit_get_route(struct navit *this_) 5354navit_get_route(struct navit *this_)
5053{ 5355{
5054#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5055 dbg(0,"+#+:enter\n");
5056#endif
5057 return this_->route; 5356 return this_->route;
5058} 5357}
5059 5358
5060struct navigation * 5359struct navigation *
5061navit_get_navigation(struct navit *this_) 5360navit_get_navigation(struct navit *this_)
5062{ 5361{
5063#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5064 dbg(0,"+#+:enter\n");
5065#endif
5066 return this_->navigation; 5362 return this_->navigation;
5067} 5363}
5068 5364
5069struct displaylist * 5365struct displaylist *
5070navit_get_displaylist(struct navit *this_) 5366navit_get_displaylist(struct navit *this_)
5071{ 5367{
5072#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
5073 dbg(0,"+#+:enter\n");
5074#endif
5075 return this_->displaylist; 5368 return this_->displaylist;
5076} 5369}
5077 5370
5078void navit_layout_switch(struct navit *n) 5371void navit_layout_switch(struct navit *n)
5079{ 5372{
5080#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5373
5081 dbg(0,"+#+:enter\n"); 5374
5082#endif
5083 ////DBG dbg(0,"EEnter\n"); 5375 ////DBG dbg(0,"EEnter\n");
5084 5376
5085 int currTs = 0; 5377 int currTs = 0;
5086 struct attr iso8601_attr, geo_attr, valid_attr, layout_attr; 5378 struct attr iso8601_attr, geo_attr, valid_attr, layout_attr;
5087 double trise, tset, trise_actual; 5379 double trise, tset, trise_actual;
5170 } 5462 }
5171} 5463}
5172 5464
5173int navit_set_vehicle_by_name(struct navit *n, const char *name) 5465int navit_set_vehicle_by_name(struct navit *n, const char *name)
5174{ 5466{
5175#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5467
5176 dbg(0,"+#+:enter\n"); 5468
5177#endif
5178 ////DBG dbg(0,"EEnter\n"); 5469 ////DBG dbg(0,"EEnter\n");
5179 5470
5180 struct vehicle *v; 5471 struct vehicle *v;
5181 struct attr_iter *iter; 5472 struct attr_iter *iter;
5182 struct attr vehicle_attr, name_attr; 5473 struct attr vehicle_attr, name_attr;
5201 return 0; 5492 return 0;
5202} 5493}
5203 5494
5204int navit_set_layout_by_name(struct navit *n, const char *name) 5495int navit_set_layout_by_name(struct navit *n, const char *name)
5205{ 5496{
5206#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5497
5207 dbg(0,"+#+:enter\n"); 5498
5208#endif
5209 ////DBG dbg(0,"EEnter\n"); 5499 ////DBG dbg(0,"EEnter\n");
5210 5500
5211 struct layout *l; 5501 struct layout *l;
5212 struct attr_iter iter; 5502 struct attr_iter iter;
5213 struct attr layout_attr; 5503 struct attr layout_attr;
5243 return 0; 5533 return 0;
5244} 5534}
5245 5535
5246void navit_disable_suspend() 5536void navit_disable_suspend()
5247{ 5537{
5248#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5538
5249 dbg(0,"+#+:enter\n"); 5539
5250#endif
5251 ////DBG dbg(0,"EEnter\n"); 5540 ////DBG dbg(0,"EEnter\n");
5252 5541
5253 gui_disable_suspend(global_navit->gui); 5542 gui_disable_suspend(global_navit->gui);
5254 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend); 5543 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend);
5255} 5544}
5271 int *f; 5560 int *f;
5272 int flags; 5561 int flags;
5273 5562
5274 if (item == NULL) 5563 if (item == NULL)
5275 { 5564 {
5276 ret_value = g_strdup_printf(""); 5565 ret_value = g_strdup("");
5277 return ret_value; 5566 return ret_value;
5278 } 5567 }
5279 5568
5280 if (pretty == 1) 5569 if (pretty == 1)
5281 { 5570 {
5448 struct map_selection sel; 5737 struct map_selection sel;
5449 struct attr street_name_attr; 5738 struct attr street_name_attr;
5450 struct attr hn_attr; 5739 struct attr hn_attr;
5451 char *ret_str = NULL; 5740 char *ret_str = NULL;
5452 5741
5453#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5742
5454 dbg(0,"+#+:enter\n"); 5743
5455#endif
5456 5744
5457 mindist = 1000; 5745 mindist = 1000;
5458 5746
5459 h = mapset_open(ms); 5747 h = mapset_open(ms);
5460 if (!h) 5748 if (!h)
5461 { 5749 {
5462 // dbg(0,"return 1\n"); 5750 // dbg(0,"return 1\n");
5463 ret_str = g_strdup_printf(""); 5751 ret_str = g_strdup("");
5464 return ret_str; 5752 return ret_str;
5465 } 5753 }
5466 5754
5467 while ((m = mapset_next(h, 0))) 5755 while ((m = mapset_next(h, 0)))
5468 { 5756 {
5539 mapset_close(h); 5827 mapset_close(h);
5540 5828
5541 if (ret_str == NULL) 5829 if (ret_str == NULL)
5542 { 5830 {
5543 // dbg(0,"was NULL\n"); 5831 // dbg(0,"was NULL\n");
5544 ret_str = g_strdup_printf(""); 5832 ret_str = g_strdup("");
5545 } 5833 }
5546 5834
5547 return ret_str; 5835 return ret_str;
5548} 5836}
5549 5837
5569 struct coord_geo g; 5857 struct coord_geo g;
5570 struct map_selection sel; 5858 struct map_selection sel;
5571 struct attr street_name_attr; 5859 struct attr street_name_attr;
5572 char *street_name = NULL; 5860 char *street_name = NULL;
5573 5861
5574#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 5862
5575 dbg(0,"+#+:enter\n"); 5863
5576#endif
5577 5864
5578 mindist = 10000; // start with small radius at the beginning! 5865 mindist = 10000; // start with small radius at the beginning!
5579 street_name = g_strdup_printf(" "); 5866 street_name = g_strdup(" ");
5580 5867
5581 h = mapset_open(ms); 5868 h = mapset_open(ms);
5582 5869
5583 if (!h) 5870 if (!h)
5584 { 5871 {
5710 struct attr street_name_attr; 5997 struct attr street_name_attr;
5711 struct attr hn_attr; 5998 struct attr hn_attr;
5712 char *street_name = NULL; 5999 char *street_name = NULL;
5713 char *street_name_saved = NULL; 6000 char *street_name_saved = NULL;
5714 6001
5715#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 6002
5716 dbg(0,"+#+:enter\n"); 6003
5717#endif
5718 6004
5719 // first find a street 6005 // first find a street
5720 street_name_saved = navit_find_nearest_street(ms, pc); 6006 street_name_saved = navit_find_nearest_street(ms, pc);
5721 // street_name = g_strdup_printf(" "); 6007 // street_name = g_strdup_printf(" ");
5722 street_name = g_strdup(street_name_saved); 6008 street_name = g_strdup(street_name_saved);
5944 int found_good = 0; 6230 int found_good = 0;
5945 struct attr street_name_attr; 6231 struct attr street_name_attr;
5946 char *street_coords = NULL; 6232 char *street_coords = NULL;
5947 char *street_coords_tmp = NULL; 6233 char *street_coords_tmp = NULL;
5948 6234
5949#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 6235
5950 dbg(0,"+#+:enter\n"); 6236
5951#endif
5952 6237
5953 mindist = 10000; // start with small radius at the beginning! 6238 mindist = 10000; // start with small radius at the beginning!
5954 street_coords = g_strdup_printf(""); 6239 street_coords = g_strdup_printf("", "");
5955 6240
5956 h = mapset_open(ms); 6241 h = mapset_open(ms);
5957 6242
5958 if (!h) 6243 if (!h)
5959 { 6244 {
6090 6375
6091// UNUSDED ------- 6376// UNUSDED -------
6092// UNUSDED ------- 6377// UNUSDED -------
6093int navit_block(struct navit *this_, int block) 6378int navit_block(struct navit *this_, int block)
6094{ 6379{
6095#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 6380
6096 dbg(0,"+#+:enter\n"); 6381
6097#endif
6098 ////DBG dbg(0,"EEnter\n"); 6382 ////DBG dbg(0,"EEnter\n");
6099 6383
6100 if (block > 0) 6384 if (block > 0)
6101 { 6385 {
6102 this_->blocked |= 1; 6386 this_->blocked |= 1;
6112 } 6396 }
6113 this_->blocked = 0; 6397 this_->blocked = 0;
6114 return 0; 6398 return 0;
6115} 6399}
6116 6400
6401FILE * navit_start_gpx_file(char *filename)
6402{
6403 char *header1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
6404 "<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n"
6405 " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
6406 " xmlns=\"http://www.topografix.com/GPX/1/1\"\n"
6407 " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"
6408 "<metadata>\n"
6409 " <name>ZANavi Debug log</name>\n"
6410 " <desc>ZANavi</desc>\n"
6411 " <author>\n"
6412 " <name>ZANavi</name>\n"
6413 " </author>\n"
6414 "</metadata>\n"
6415 "<trk>\n"
6416 "<trkseg>\n"
6417 " <name>ACTIVE LOG</name>\n";
6418
6419 FILE *fp;
6420
6421 if (filename)
6422 {
6423 fp = fopen(filename,"w");
6424 }
6425 else
6426 {
6427 fp = fopen("/sdcard/zanavi_debug_001.gpx","w");
6428 }
6429
6430 fprintf(fp, "%s", header1);
6431
6432 return fp;
6433}
6434
6435void navit_add_trkpoint_to_gpx_file(FILE *fp, struct coord *c)
6436{
6437 struct coord_geo g;
6438 transform_to_geo(projection_mg, c, &g);
6439 fprintf(fp, " <trkpt lat='%4.6f' lon='%4.6f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng);
6440}
6441
6442
6443void navit_end_gpx_track_seg(FILE *fp)
6444{
6445 fprintf(fp,"</trkseg>\n</trk>\n");
6446}
6447
6448void navit_start_gpx_track_seg(FILE *fp)
6449{
6450 fprintf(fp,"<trk>\n<trkseg>\n");
6451}
6452
6453
6454void navit_end_gpx_file(FILE *fp)
6455{
6456 char *trailer1= "</trkseg>\n"
6457 "</trk>\n"
6458 "</gpx>\n";
6459
6460 fprintf(fp,"%s",trailer1);
6461 fclose(fp);
6462}
6463
6464void navit_route_export_gpx_to_file(struct navit *this_, char *filename)
6465{
6466
6467
6468
6469 dbg(0,"Dumping route to %s\n", filename);
6470
6471 struct point p;
6472 struct map *map=NULL;
6473 struct navigation *nav = NULL;
6474 struct map_rect *mr=NULL;
6475 struct item *item =NULL;
6476 struct attr attr,route;
6477 struct coord c;
6478 struct coord_geo g;
6479 struct transformation *trans;
6480
6481 char *header1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
6482 "<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n"
6483 " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
6484 " xmlns=\"http://www.topografix.com/GPX/1/1\"\n"
6485 " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"
6486 "<metadata>\n"
6487 " <name>ZANavi Track log</name>\n"
6488 " <desc>ZANavi</desc>\n"
6489 " <author>\n"
6490 " <name>ZANavi</name>\n"
6491 " </author>\n"
6492 "</metadata>\n"
6493 "<trk>\n"
6494 "<trkseg>\n"
6495 " <name>ACTIVE LOG</name>\n";
6496
6497 char *trailer1= "</trkseg>\n"
6498 "</trk>\n";
6499
6500// char *trkcolor= "<extensions>\n"
6501// " <gpxx:TrackExtension>\n"
6502// " <gpxx:DisplayColor>Magenta</gpxx:DisplayColor>\n"
6503// " </gpxx:TrackExtension>\n"
6504// "</extensions>\n";
6505
6506 char *header2 = "<rte>\n";
6507
6508 char *trailer2= "</rte>\n"
6509 "</gpx>\n";
6510
6511
6512 // -------- full route ---------
6513 // -------- full route ---------
6514 struct route *route2 = NULL;
6515 struct map *route_map2 = NULL;
6516 struct map_rect *mr2 = NULL;
6517 struct item *item2 = NULL;
6518 struct coord c2;
6519
6520 route2 = navit_get_route(this_);
6521
6522 if (route2)
6523 {
6524 route_map2 = route_get_map(route2);
6525 }
6526
6527 if (route_map2)
6528 {
6529 mr2 = map_rect_new(route_map2, NULL);
6530 }
6531
6532 if (mr2)
6533 {
6534 item2 = map_rect_get_item(mr2);
6535 }
6536
6537 if (item2 && item2->type == type_route_start)
6538 {
6539 item2 = map_rect_get_item(mr2);
6540 }
6541
6542 FILE *fp;
6543 fp = fopen(filename,"w");
6544 fprintf(fp, "%s", header1);
6545 int first3 = 0;
6546
6547 if (item2 && item_coord_get(item2, &c2, 1))
6548 {
6549 transform_to_geo(projection_mg, &c2, &g);
6550 fprintf(fp, " <trkpt lat='%4.16f' lon='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng);
6551
6552 while (item2)
6553 {
6554 if (!item_coord_get(item2, &c2, 1))
6555 {
6556 item2 = map_rect_get_item(mr2);
6557 first3 = 1;
6558 continue;
6559 }
6560
6561 if (first3 == 0)
6562 {
6563 transform_to_geo(projection_mg, &c2, &g);
6564 fprintf(fp, " <trkpt lat='%4.16f' lon='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lat, g.lng);
6565 }
6566 else
6567 {
6568 first3 = 0;
6569 // fprintf(fp, "Y**********\n");
6570 }
6571 }
6572 }
6573
6574 map_rect_destroy(mr2);
6575
6576 // -------- full route ---------
6577 // -------- full route ---------
6578
6579
6580
6581
6582
6583 nav = navit_get_navigation(this_);
6584
6585 if (!nav)
6586 {
6587 return;
6588 }
6589
6590 map = navigation_get_map(nav);
6591
6592 if (map)
6593 {
6594 mr = map_rect_new(map,NULL);
6595 }
6596 else
6597 {
6598 return;
6599 }
6600
6601 trans = navit_get_trans(this_);
6602
6603
6604 //while((item = map_rect_get_item(mr)))
6605 //{
6606 // item_coord_get(item, &c, 1);
6607 // transform_to_geo(projection_mg, &c, &g);
6608 // fprintf(fp, " <trkpt lon='%4.16f' lat='%4.16f'><time>2014-10-02T09:30:10Z</time></trkpt>\n", g.lng, g.lat);
6609 //}
6610 map_rect_destroy(mr);
6611
6612
6613
6614 fprintf(fp,"%s",trailer1);
6615
6616
6617
6618 mr = map_rect_new(map,NULL);
6619 while ((item = map_rect_get_item(mr)))
6620 {
6621 if (item_attr_get(item, attr_navigation_long, &attr))
6622 {
6623 item_coord_get(item, &c, 1);
6624 transform_to_geo(projection_mg, &c, &g);
6625 fprintf(fp, "<wpt lat=\"%4.16f\" lon=\"%4.16f\"><time>2014-10-02T09:30:10Z</time><name>%s:%s</name><sym>Dot</sym><type>Dot></type></wpt>\n", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str));
6626 }
6627 else
6628 {
6629 // must be the start point (without navigation command)
6630 item_coord_get(item, &c, 1);
6631 transform_to_geo(projection_mg, &c, &g);
6632 fprintf(fp, "<wpt lat=\"%4.16f\" lon=\"%4.16f\"><time>2014-10-02T09:30:10Z</time><name>START</name><sym>Dot</sym><type>Dot></type></wpt>\n", g.lat, g.lng);
6633 }
6634 }
6635 map_rect_destroy(mr);
6636
6637
6638
6639 fprintf(fp,"%s",header2);
6640
6641
6642
6643 mr = map_rect_new(map,NULL);
6644 while ((item = map_rect_get_item(mr)))
6645 {
6646 if (item_attr_get(item, attr_navigation_long, &attr))
6647 {
6648 item_coord_get(item, &c, 1);
6649 transform_to_geo(projection_mg, &c, &g);
6650 fprintf(fp, "<rtept lat='%4.16f' lon='%4.16f'><name>%s:%s</name></rtept>\n", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str));
6651 }
6652 else
6653 {
6654 // must be the start point (without navigation command)
6655 item_coord_get(item, &c, 1);
6656 transform_to_geo(projection_mg, &c, &g);
6657 fprintf(fp, "<rtept lat='%4.16f' lon='%4.16f'><name>START</name></rtept>\n", g.lat, g.lng);
6658 }
6659 }
6660 map_rect_destroy(mr);
6661
6662 fprintf(fp,"%s",trailer2);
6663
6664 fclose(fp);
6665
6666#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
6667 dbg(0,"+#+:leave\n");
6668#endif
6669
6670}
6671
6672
6117void navit_destroy(struct navit *this_) 6673void navit_destroy(struct navit *this_)
6118{ 6674{
6119#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 6675
6120 dbg(0,"+#+:enter\n"); 6676
6121#endif
6122 dbg(0, "EEnter\n"); 6677 dbg(0, "EEnter\n");
6123 6678
6124 struct mapset*ms; 6679 struct mapset*ms;
6125 callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_); 6680 callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_);
6126 6681

Legend:
Removed from v.39  
changed lines
  Added in v.40

   
Visit the ZANavi Wiki