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

Contents of /navit/navit/android.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations) (download)
Sun Mar 19 08:44:36 2017 UTC (7 years ago) by zoff99
File MIME type: text/plain
File size: 108899 byte(s)
updates
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2014 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include <stdlib.h>
21 #include <string.h>
22 #include <poll.h>
23 #include <glib.h>
24 #include "android.h"
25 #include <android/log.h>
26 #include <android/bitmap.h>
27 #include "navit.h"
28 #include "config_.h"
29 #include "command.h"
30 #include "debug.h"
31 #include "event.h"
32 #include "callback.h"
33 #include "projection.h"
34 #include "map.h"
35 #include "transform.h"
36 #include "color.h"
37 #include "types.h"
38 #include "search.h"
39 #include "start_real.h"
40 #include "route.h"
41 #include "track.h"
42 #include "file.h"
43 #include "roadprofile.h"
44 #include "navit_nls.h"
45
46 #include "coffeecatch.h"
47 #include "coffeejni.h"
48
49 // #include "layout.h"
50
51 JNIEnv *jnienv;
52 jobject *android_activity;
53 jobject *main_map_bitmap;
54 AndroidBitmapInfo *main_map_bitmapinfo;
55 struct callback_list *android_activity_cbl;
56 int android_version;
57
58 jclass NavitGraphicsClass2 = NULL;
59 jmethodID return_generic_int;
60 jmethodID send_generic_text;
61 jclass NavitMapPreviewActivityClass = NULL;
62 jmethodID DrawMapPreview_target;
63 jmethodID DrawMapPreview_polyline = NULL;
64 jmethodID DrawPreview_polyline = NULL;
65 jmethodID DrawMapPreview_text = NULL;
66 jmethodID NavitGraphics_send_osd_values2 = NULL;
67 jmethodID NavitGraphics_set_vehicle_values2 = NULL;
68 jmethodID NavitGraphics_set_vehicle_values3 = NULL;
69 jmethodID NavitGraphics_send_route_rect_to_java = NULL;
70 jmethodID NavitGraphics_alter_missing_icon = NULL;
71
72 struct attr attr;
73
74
75
76
77
78
79
80 // #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
81
82
83 // --------------- debug function calls ------------------
84 // --------------- debug function calls ------------------
85 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
86 #undef return2
87 #define return2 dbg_func(0, global_func_indent_counter, "return(%d)\n", __LINE__);global_func_indent_counter--;return
88
89 #define __F_START__ global_func_indent_counter++;dbg_func(0, global_func_indent_counter, "enter\n");
90 #define __F_END__ dbg_func(0, global_func_indent_counter, "leave\n");global_func_indent_counter--;
91 #else
92 #undef return2
93 #define return2 return
94
95 #define __F_START__
96 #define __F_END__
97 #endif
98 // --------------- debug function calls ------------------
99 // --------------- debug function calls ------------------
100
101
102
103
104
105
106
107
108
109
110 // ------------------------- COPIED STUFF --- this is generally bad ------------------
111 // ------------------------- COPIED STUFF --- this is generally bad ------------------
112 // ------------------------- COPIED STUFF --- this is generally bad ------------------
113
114
115 // copyied from config_.c !!! (always keep in sync!!!)
116 struct config
117 {
118 struct attr **attrs;
119 struct callback_list *cbl;
120 }*config;
121
122 // copied from gui_internal.c (always keep in sync!!!)
123 struct gui_config_settings
124 {
125 int font_size;
126 int icon_xs;
127 int icon_s;
128 int icon_l;
129 int spacing;
130 };
131
132 // dummy def!!
133 struct gui_internal_methods
134 {
135 int dummy;
136 };
137
138 // dummy def!!
139 struct gui_internal_widget_methods
140 {
141 int dummy;
142 };
143
144 // forward def
145 struct gui_priv;
146
147 // copied from gui_internal.h (always keep in sync!!!)
148 struct gui_internal_data
149 {
150 struct gui_priv *priv;
151 struct gui_internal_methods *gui;
152 struct gui_internal_widget_methods *widget;
153 };
154
155 // copied from gui_internal.c (always keep in sync!!!)
156 struct route_data
157 {
158 struct widget * route_table;
159 int route_showing;
160
161 };
162
163 // copied from gui_internal.h (always keep in sync!!!)
164 enum flags
165 {
166 gravity_none = 0x00, gravity_left = 1, gravity_xcenter = 2, gravity_right = 4, gravity_top = 8, gravity_ycenter = 16, gravity_bottom = 32, gravity_left_top = gravity_left | gravity_top, gravity_top_center = gravity_xcenter | gravity_top, gravity_right_top = gravity_right | gravity_top, gravity_left_center = gravity_left | gravity_ycenter, gravity_center = gravity_xcenter | gravity_ycenter, gravity_right_center = gravity_right | gravity_ycenter, gravity_left_bottom = gravity_left | gravity_bottom, gravity_bottom_center = gravity_xcenter | gravity_bottom, gravity_right_bottom = gravity_right | gravity_bottom, flags_expand = 0x100, flags_fill = 0x200, orientation_horizontal = 0x10000, orientation_vertical = 0x20000, orientation_horizontal_vertical = 0x40000,
167 };
168
169 // copied from gui_internal.h (always keep in sync!!!)
170 enum widget_type
171 {
172 widget_box = 1, widget_button, widget_label, widget_image, widget_table, widget_table_row
173 };
174
175 // copied from gui_internal.c (always keep in sync!!!)
176 struct widget
177 {
178 enum widget_type type;
179 struct graphics_gc *background, *text_background;
180 struct graphics_gc *foreground_frame;
181 struct graphics_gc *foreground;
182 char *text;
183 struct graphics_image *img;
184 void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
185 int reason;
186 int datai;
187 void *data;
188 void (*data_free)(void *data);
189 void (*free)(struct gui_priv *this_, struct widget * w);
190 char *prefix;
191 char *name;
192 char *speech;
193 char *command;
194 struct pcoord c;
195 struct item item;
196 int selection_id;
197 int state;
198 struct point p;
199 int wmin, hmin;
200 int w, h;
201 int textw, texth;
202 int font_idx;
203 int bl, br, bt, bb, spx, spy;
204 int border;
205 int packed;
206 int cols;
207 enum flags flags;
208 int flags2;
209 void *instance;
210 int (*set_attr)(void *, struct attr *);
211 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
212 void (*remove_cb)(void *, struct callback *cb);
213 struct callback *cb;
214 struct attr on;
215 struct attr off;
216 int deflt;
217 int is_on;
218 int redraw;
219 struct menu_data *menu_data;
220 struct form *form;
221 GList *children;
222 };
223
224 // copied from gui_internal.c !!!!!! (always keep in sync!!!)
225 struct gui_priv
226 {
227 struct navit *nav;
228 struct attr self;
229 struct window *win;
230 struct graphics *gra;
231 struct graphics_gc *background;
232 struct graphics_gc *background2;
233 struct graphics_gc *highlight_background;
234 struct graphics_gc *foreground;
235 struct graphics_gc *text_foreground;
236 struct graphics_gc *text_background;
237 struct color background_color, background2_color, text_foreground_color, text_background_color;
238 int spacing;
239 int font_size;
240 int fullscreen;
241 struct graphics_font *fonts[3];
242 int icon_xs;
243 int icon_s;
244 int icon_l;
245 int pressed;
246 struct widget *widgets;
247 int widgets_count;
248 int redraw;
249 struct widget root;
250 struct widget *highlighted, *editable;
251 struct widget *highlighted_menu;
252 int clickp_valid, vehicle_valid;
253 struct pcoord clickp, vehiclep;
254 struct attr *click_coord_geo, *position_coord_geo;
255 struct search_list *sl;
256 int ignore_button;
257 int menu_on_map_click;
258 int signal_on_map_click;
259 char *country_iso2;
260 int speech;
261 int keyboard;
262 int keyboard_required;
263 struct gui_config_settings config;
264 struct event_idle *idle;
265 struct callback *motion_cb, *button_cb, *resize_cb, *keypress_cb, *window_closed_cb, *idle_cb, *motion_timeout_callback;
266 struct event_timeout *motion_timeout_event;
267 struct point current;
268 struct callback * vehicle_cb;
269 struct route_data route_data;
270 struct gui_internal_data data;
271 struct callback_list *cbl;
272 int flags;
273 int cols;
274 struct attr osd_configuration;
275 int pitch;
276 int flags_town, flags_street, flags_house_number;
277 int radius;
278 char *html_text;
279 int html_depth;
280 struct widget *html_container;
281 int html_skip;
282 char *html_anchor;
283 char *href;
284 int html_anchor_found;
285 struct form *form;
286 struct html
287 {
288 int skip;
289 enum html_tag
290 {
291 html_tag_none, html_tag_a, html_tag_h1, html_tag_html, html_tag_img, html_tag_script, html_tag_form, html_tag_input, html_tag_div,
292 } tag;
293 char *command;
294 char *name;
295 char *href;
296 char *refresh_cond;
297 struct widget *w;
298 struct widget *container;
299 } html[10];
300 };
301
302
303 // copied from graphics_android.c !!!!!! (always keep in sync!!!)
304 struct graphics_priv
305 {
306 jclass NavitGraphicsClass;
307 jmethodID NavitGraphics_draw_polyline, NavitGraphics_draw_polyline2, NavitGraphics_draw_polyline3, NavitGraphics_draw_polyline4, NavitGraphics_draw_polyline_dashed, NavitGraphics_set_dashes, NavitGraphics_draw_polygon, NavitGraphics_draw_polygon2, NavitGraphics_draw_rectangle, NavitGraphics_draw_circle, NavitGraphics_draw_text, NavitGraphics_draw_image,
308 NavitGraphics_draw_bigmap, NavitGraphics_draw_image_warp, NavitGraphics_draw_mode, NavitGraphics_draw_drag, NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera, NavitGraphicsClass_rotate_and_scale_bitmap;
309
310 jclass PaintClass;
311 jmethodID Paint_init, Paint_setStrokeWidth, Paint_setARGB;
312
313 jobject NavitGraphics;
314 jobject Paint;
315
316 jclass BitmapFactoryClass;
317 jmethodID BitmapFactory_decodeFile, BitmapFactory_decodeResource;
318
319 jclass BitmapClass;
320 jmethodID Bitmap_getHeight, Bitmap_getWidth;
321
322 jclass ContextClass;
323 jmethodID Context_getResources;
324
325 jclass ResourcesClass;
326 jobject Resources;
327 jmethodID Resources_getIdentifier;
328
329 };
330
331 // copied from graphics.c !!!!!! (always keep in sync!!!)
332 struct graphics
333 {
334 struct graphics_priv *priv;
335 };
336
337
338 // ------------------------- COPIED STUFF --- this is generally bad ------------------
339 // ------------------------- COPIED STUFF --- this is generally bad ------------------
340 // ------------------------- COPIED STUFF --- this is generally bad ------------------
341
342
343 JavaVM *cachedJVM = NULL;
344
345 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
346 {
347 JNIEnv *env_this;
348 cachedJVM = jvm;
349 if ((*jvm)->GetEnv(jvm, (void**) &env_this, JNI_VERSION_1_6))
350 {
351 // dbg(0,"Could not get JVM\n");
352 return JNI_ERR;
353 }
354
355 // dbg(0,"++ Found JVM ++\n");
356 return JNI_VERSION_1_6;
357 }
358
359 JNIEnv* jni_getenv()
360 {
361 JNIEnv* env_this;
362 (*cachedJVM)->GetEnv(cachedJVM, (void**) &env_this, JNI_VERSION_1_6);
363 return env_this;
364 }
365
366 static void gui_internal_search_list_set_default_country2(struct gui_priv *this)
367 {
368 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
369 dbg(0,"+#+:enter\n");
370 #endif
371 struct attr search_attr, country_name, country_iso2, *country_attr;
372 struct item *item;
373 struct country_search *cs;
374 struct tracking *tracking;
375 struct search_list_result *res;
376
377 ////DBG // dbg(0,"### 1");
378
379 country_attr = country_default();
380 tracking = navit_get_tracking(this->nav);
381
382 if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
383 country_attr = &search_attr;
384 if (country_attr)
385 {
386 ////DBG // dbg(0,"### 2");
387 cs = country_search_new(country_attr, 0);
388 item = country_search_get_item(cs);
389 if (item && item_attr_get(item, attr_country_name, &country_name))
390 {
391 search_attr.type = attr_country_all;
392 ////DBG // dbg(0,"country %s\n", country_name.u.str);
393 search_attr.u.str = country_name.u.str;
394 search_list_search(this->sl, &search_attr, 0);
395 while ((res = search_list_get_result(this->sl)))
396 ;
397 if (this->country_iso2)
398 {
399 // this seems to cause a crash, no idea why
400 //g_free(this->country_iso2);
401 this->country_iso2 = NULL;
402 }
403 if (item_attr_get(item, attr_country_iso2, &country_iso2))
404 {
405 this->country_iso2 = g_strdup(country_iso2.u.str);
406 }
407 }
408 country_search_destroy(cs);
409 }
410 else
411 {
412 //DBG // dbg(0, "warning: no default country found\n");
413 if (this->country_iso2)
414 {
415 //DBG // dbg(0, "attempting to use country '%s'\n", this->country_iso2);
416 search_attr.type = attr_country_iso2;
417 search_attr.u.str = this->country_iso2;
418 search_list_search(this->sl, &search_attr, 0);
419 while ((res = search_list_get_result(this->sl)))
420 ;
421 }
422 }
423 ////DBG // dbg(0,"### 99");
424 }
425
426 // forward rev
427 struct navit *global_navit;
428
429 int android_find_class_global(char *name, jclass *ret)
430 {
431 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
432 dbg(0,"+#+:enter\n");
433 #endif
434
435 JNIEnv *jnienv2;
436 jnienv2 = jni_getenv();
437
438 *ret = (*jnienv2)->FindClass(jnienv2, name);
439 if (!*ret)
440 {
441 //DBG // dbg(0, "Failed to get Class %s\n", name);
442 return 0;
443 }
444 //DBG // dbg(0,"lclass %p\n", *ret);
445 *ret = (*jnienv2)->NewGlobalRef(jnienv2, *ret);
446 // ICS (*jnienv2)->DeleteGlobalRef(jnienv2, *lret);
447 //DBG // dbg(0,"gclass %p\n", *ret);
448 return 1;
449 }
450
451 int android_find_method(jclass class, char *name, char *args, jmethodID *ret)
452 {
453 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
454 dbg(0,"+#+:enter\n");
455 #endif
456
457 JNIEnv *jnienv2;
458 jnienv2 = jni_getenv();
459
460 *ret = (*jnienv2)->GetMethodID(jnienv2, class, name, args);
461 if (*ret == NULL)
462 {
463 //DBG // dbg(0, "Failed to get Method %s with signature %s\n", name, args);
464 return 0;
465 }
466 //DBG // dbg(0,"l meth %p\n", *ret);
467 return 1;
468 }
469
470 int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret)
471 {
472 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
473 dbg(0,"+#+:enter\n");
474 #endif
475
476 JNIEnv *jnienv2;
477 jnienv2 = jni_getenv();
478
479 *ret = (*jnienv2)->GetStaticMethodID(jnienv2, class, name, args);
480 if (*ret == NULL)
481 {
482 //DBG // dbg(0, "Failed to get static Method %s with signature %s\n", name, args);
483 return 0;
484 }
485 //DBG // dbg(0,"l meth %p\n", *ret);
486 return 1;
487 }
488
489
490 void send_alert_to_java(int id, const char *text);
491 void android_DrawMapPreview_target(int x, int y);
492 void android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy);
493 void android_DrawMapPreview_polyline(struct point *p, int count, int type);
494 void android_DrawPreview_polyline(struct point *p, int count, int type, const char* item_type);
495
496
497 // #include <signal.h>
498 Java_com_zoffcc_applications_zanavi_Navit_AppCrashC__XX_real(JNIEnv* env, jobject thiz) __attribute__((optimize("-O0")));
499 Java_com_zoffcc_applications_zanavi_Navit_AppCrashC__XX_real(JNIEnv* env, jobject thiz) __attribute__((optimize("O0")));
500 Java_com_zoffcc_applications_zanavi_Navit_AppCrashC__XX_real(JNIEnv* env, jobject thiz)
501 {
502 send_alert_to_java(99, "app_crash_C:003");
503
504 int i = 3;
505 i = (1 / 0);
506
507 char* name = NULL;
508 name = (char*)0;
509 name = "ekrpowekrp";
510
511 int *pi;
512 int c;
513 pi = NULL;
514 c = *pi;
515
516 int *x = NULL;
517 int y = *x;
518 y = y + 1;
519
520 *(long*)0 = 0xDEADBEEF;
521
522 send_alert_to_java(99, "app_crash_C:004");
523 }
524
525 JNIEXPORT void JNICALL
526 Java_com_zoffcc_applications_zanavi_Navit_AppCrashC(JNIEnv* env, jobject thiz)
527 {
528 // dbg(0,"app_crash_C:001\n");
529 send_alert_to_java(99, "app_crash_C:001");
530 COFFEE_TRY_JNI(env, Java_com_zoffcc_applications_zanavi_Navit_AppCrashC__XX_real(env, thiz));
531 send_alert_to_java(99, "app_crash_C:002");
532 // dbg(0,"app_crash_C:099\n");
533 }
534
535
536 JNIEXPORT void JNICALL
537 Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string, jobject n_datadir, jobject n_sharedir, jobject bitmap)
538 {
539 COFFEE_TRY_JNI(env, Java_com_zoffcc_applications_zanavi_Navit_NavitMain__XX_real(env, thiz, activity, lang, version, display_density_string, n_datadir, n_sharedir, bitmap));
540 }
541
542 Java_com_zoffcc_applications_zanavi_Navit_NavitMain__XX_real(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string, jobject n_datadir, jobject n_sharedir, jobject bitmap)
543 {
544 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
545 dbg(0,"+#+:enter\n");
546 #endif
547
548 #ifdef DEBUG_GLIB_MEM_FUNCTIONS
549 // GLIB debugging
550 // GLIB debugging
551 // GLIB debugging
552 /*
553 dbg(0,"GLIB debugging ----------------------");
554 dbg(0,"GLIB debugging ----------------------");
555 dbg(0,"GLIB debugging ----------------------");
556 dbg(0,"GLIB debugging ----------------------");
557 dbg(0,"GLIB debugging ----------------------");
558 dbg(0,"GLIB debugging ----------------------");
559 dbg(0,"GLIB debugging ----------------------");
560 dbg(0,"GLIB debugging ----------------------");
561 dbg(0,"GLIB debugging 1 --------------------");
562 */
563 //*******???******** g_mem_set_vtable(glib_mem_profiler_table);
564 //char *dummy_997;
565 //dummy_997 = g_malloc(1024*1024*10); // 10 MByte
566 //g_free(dummy_997);
567 //dummy_997 = NULL;
568 //g_mem_profile();
569 /*
570 dbg(0,"GLIB debugging 2 --------------------");
571 dbg(0,"GLIB debugging ----------------------");
572 dbg(0,"GLIB debugging ----------------------");
573 dbg(0,"GLIB debugging ----------------------");
574 dbg(0,"GLIB debugging ----------------------");
575 dbg(0,"GLIB debugging ----------------------");
576 dbg(0,"GLIB debugging ----------------------");
577 dbg(0,"GLIB debugging ----------------------");
578 dbg(0,"GLIB debugging ----------------------");
579 */
580 // GLIB debugging
581 // GLIB debugging
582 // GLIB debugging
583 #endif
584
585 int thread_id = gettid();
586 // dbg(0, "THREAD ID=%d\n", thread_id);
587
588 char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL };
589 const char *langstr;
590 const char *displaydensitystr;
591 const char *s;
592 android_version = version;
593 //__android_log_print(ANDROID_LOG_ERROR,"test","called");
594 android_activity_cbl = callback_list_new("Java_com_zoffcc_applications_zanavi_Navit_NavitMain:android_activity_cbl");
595
596 // SET GLOBAL JNIENV here, this is bad!!
597 // SET GLOBAL JNIENV here, this is bad!!
598 // SET GLOBAL JNIENV here, this is bad!!
599 jnienv = env;
600 // dbg(0,"jnienv=%p\n", env);
601 // SET GLOBAL JNIENV here, this is bad!!
602 // SET GLOBAL JNIENV here, this is bad!!
603 // SET GLOBAL JNIENV here, this is bad!!
604
605 //jclass someClass = env->FindClass("SomeClass");
606 //gSomeClass = env->NewGlobalRef(someClass);
607
608
609
610 #if 0
611 // runtime TEST INT / FLOAT ----------
612 // runtime TEST INT / FLOAT ----------
613 // runtime TEST INT / FLOAT ----------
614 int v1 = 27;
615 int v2 = 13;
616 int r2;
617 int r3;
618
619 int ij1a;
620 int ccc = 10000000;
621 clock_t s_;
622
623 s_ = debug_measure_start();
624 for (ij1a=0; ij1a < ccc; ij1a++)
625 {
626 r2 = ( v1 * 100 * (v2 * 10.0 ) / 10000);
627 }
628 debug_mrp("TEST:INT :", debug_measure_end(s_));
629
630 s_ = debug_measure_start();
631 for (ij1a=0; ij1a < ccc; ij1a++)
632 {
633 r3 = (int)( (float)v1 * ((float)v2 / 10.0f ));
634 }
635 debug_mrp("TEST:FLOAT:", debug_measure_end(s_));
636 // runtime TEST INT / FLOAT ----------
637 // runtime TEST INT / FLOAT ----------
638 // runtime TEST INT / FLOAT ----------
639 #endif
640
641
642
643 main_map_bitmap = (*env)->NewGlobalRef(env, bitmap); // --> ANDROID_BITMAP_FORMAT_RGBA_8888
644 main_map_bitmapinfo = NULL;
645
646 // enum AndroidBitmapFormat {
647 // ANDROID_BITMAP_FORMAT_NONE = 0,
648 // ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
649 // ANDROID_BITMAP_FORMAT_RGB_565 = 4,
650 // ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
651 // ANDROID_BITMAP_FORMAT_A_8 = 8,
652 // };
653
654
655 // *only local* android_activity = activity;
656 // android_activity = (*jnienv)->NewGlobalRef(jnienv, activity);
657 android_activity = (*env)->NewGlobalRef(env, activity);
658 langstr = (*env)->GetStringUTFChars(env, lang, NULL);
659 //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version);
660 //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version);
661 setenv("LANG", langstr, 1);
662 (*env)->ReleaseStringUTFChars(env, lang, langstr);
663
664 s = (*env)->GetStringUTFChars(env, n_datadir, NULL);
665 navit_data_dir = g_strdup(s);
666 (*env)->ReleaseStringUTFChars(env, n_datadir, s);
667
668 s = (*env)->GetStringUTFChars(env, n_sharedir, NULL);
669 navit_share_dir = g_strdup(s);
670 (*env)->ReleaseStringUTFChars(env, n_sharedir, s);
671
672
673 displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL);
674 dbg(0, "*****displaydensity=%s\n", displaydensitystr);
675 setenv("ANDROID_DENSITY", displaydensitystr, 1);
676
677 // calc DPI value
678 global_have_dpi_value = atoi(displaydensitystr);
679 dbg(0, "*****displaydensity int=%d\n", (int) global_have_dpi_value);
680
681 if (global_have_dpi_value >= 320)
682 {
683 global_dpi_factor = (float) global_have_dpi_value / 240.0f; // multiply with this factor where needed!
684 }
685 else
686 {
687 global_dpi_factor = 1.0f;
688 }
689
690 (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr);
691
692 //// dbg(0,"before main_real call\n");
693 //main_real(1, strings);
694 //// dbg(0,"after main_real call\n");
695
696 /* -- mem test --
697 char *dummy_99;
698 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
699 g_free(dummy_99);
700 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
701 g_free(dummy_99);
702 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
703 g_free(dummy_99);
704 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
705 g_free(dummy_99);
706 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
707 g_free(dummy_99);
708 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
709 g_free(dummy_99);
710 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
711 g_free(dummy_99);
712 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
713 g_free(dummy_99);
714 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
715 g_free(dummy_99);
716 dummy_99 = g_malloc(1024*1024*10); // 10 MByte
717 g_free(dummy_99);
718 dummy_997 = NULL;
719 */
720
721
722
723 #if 0
724
725 double lat = 48.6936931;
726 double lon = 16.0135909;
727 float latf = 48.6936931;
728 float lonf = 16.0135909;
729
730
731 //transform_to_geo_lat(transform_from_geo_lat(lat));
732 //transform_to_geo_lon(transform_from_geo_lon(lon));
733
734
735 long long j=0;
736 double ddd;
737 int in_y=12278278;
738
739 clock_t s_;
740 clock_t diff_time;
741
742 s_ = clock();
743 for(j=0;j<10000000L;j++)
744 {
745 ddd = atan(exp((in_y/2.00) / 6378137.0)) / M_PI * 360 - 90;
746 }
747 diff_time = clock() - s_;
748 dbg(0, "1:%fs\n", (double) ((double) diff_time / (double) CLOCKS_PER_SEC));
749
750 s_ = clock();
751 for(j=0;j<10000000L;j++)
752 {
753 ddd = TO_GEO_LAT_(in_y);
754 // fprintf(stderr, "lon=%.17f\n", ddd);
755 }
756 diff_time = clock() - s_;
757 dbg(0, "2:%fs\n", (double) ((double) diff_time / (double) CLOCKS_PER_SEC));
758
759 s_ = clock();
760 for(j=0;j<10000000L;j++)
761 {
762 ddd = TO_GEO_LAT_FAST_(in_y);
763 }
764 diff_time = clock() - s_;
765 dbg(0, "3:%fs\n", (double) ((double) diff_time / (double) CLOCKS_PER_SEC));
766
767
768 #endif
769
770
771
772
773
774 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
775 dbg(0,"+#+:leave\n");
776 #endif
777
778 }
779
780 JNIEXPORT void JNICALL
781 Java_com_zoffcc_applications_zanavi_Navit_NavitActivity(JNIEnv* env, jobject thiz, int param)
782 {
783 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
784 dbg(0,"+#+:enter\n");
785 #endif
786
787 dbg(0, "enter %d\n", param);
788
789 int thread_id = gettid();
790 // dbg(0, "THREAD ID=%d\n", thread_id);
791
792 #ifndef NAVIT_DEBUG_BAREMETAL
793
794 if (param == -2)
795 {
796 // onStop() -> called in Java app
797 // save center.txt
798 if (global_navit->bookmarks)
799 {
800 config_get_attr(config, attr_navit, &attr, NULL);
801 //DBG // dbg(0, "save position to file");
802 char *center_file = bookmarks_get_center_file(TRUE);
803 bookmarks_write_center_to_file(attr.u.navit->bookmarks, center_file);
804 // dbg(0, "save pos to file -> ready");
805 g_free(center_file);
806 // bookmarks_destroy(global_navit->bookmarks);
807 }
808 }
809 #endif
810
811 // param == 3 // onCreate
812 // param == 2 // onStart
813 // param == 1 // onResume
814 // param == 0 // onRestart
815 // param == -1 // onPause
816 // param == -2 // onStop
817 // param == -3 // onDestroy
818 // param == -4 // exit() [java function]
819
820
821 if (param == 3)
822 {
823 // in onCreate at startup
824 char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL };
825
826 // ------------ send initial values for GEO calcs to Java ---------------
827 // ------------ send initial values for GEO calcs to Java ---------------
828 char *temp_t = NULL;
829
830 temp_t = g_strdup_printf("%.17f\n", (double)__EARTH_RADIUS__);
831 android_send_generic_text(21, temp_t);
832 g_free(temp_t);
833
834 temp_t = g_strdup_printf("%.17f\n", (double)__GEO_ACCURACY_FACTOR__);
835 android_send_generic_text(22, temp_t);
836 g_free(temp_t);
837
838 temp_t = NULL;
839 // ------------ send initial values for GEO calcs to Java ---------------
840 // ------------ send initial values for GEO calcs to Java ---------------
841
842 // dbg(0,"before main_real call\n");
843 main_real(1, strings);
844 // dbg(0,"after main_real call\n");
845
846 #ifndef NAVIT_DEBUG_BAREMETAL
847 navit_draw(global_navit);
848 #endif
849 }
850
851
852 // dbg(0, "acti: 001\n");
853 // callback_list_call_1(android_activity_cbl, param);
854 //// dbg(0, "acti: 002\n");
855
856 //if (param == -4)
857 //{
858 // // dbg(0, "acti: 003\n");
859 // // *********EXIT******EXIT******** // exit(0);
860 //}
861
862 #ifndef NAVIT_DEBUG_BAREMETAL
863 if (param == -4)
864 {
865 // dbg(0, "acti: 004\n");
866 navit_destroy(global_navit);
867 // dbg(0, "acti: 005\n");
868 event_main_loop_quit();
869 // dbg(0, "acti: 006\n");
870 }
871 #endif
872
873 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
874 dbg(0,"+#+:leave\n");
875 #endif
876 }
877
878 JNIEXPORT void JNICALL
879 Java_com_zoffcc_applications_zanavi_NavitGraphics_SizeChangedCallbackReal(JNIEnv* env, jobject thiz, int w, int h, jobject bitmap)
880 {
881 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
882 dbg(0,"+#+:enter\n");
883 #endif
884 // dbg(0,"enter %d %d\n", w, h);
885
886 int thread_id = gettid();
887 // dbg(0, "THREAD ID=%d\n", thread_id);
888
889
890 #ifndef NAVIT_DEBUG_BAREMETAL
891
892 if (main_map_bitmap)
893 {
894 (*env)->DeleteGlobalRef(env, main_map_bitmap);
895 }
896 main_map_bitmap = (*env)->NewGlobalRef(env, bitmap); // --> ANDROID_BITMAP_FORMAT_RGBA_8888
897 main_map_bitmapinfo = NULL;
898
899 navit_handle_resize(global_navit, w, h);
900
901 #endif
902
903 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
904 dbg(0,"+#+:leave\n");
905 #endif
906 }
907
908 JNIEXPORT void JNICALL
909 Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallbackReal(JNIEnv* env, jobject thiz, int x1, int y1, int x2, int y2, int draw)
910 {
911 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
912 dbg(0,"+#+:enter\n");
913 #endif
914
915 //int thread_id = gettid();
916 // dbg(0, "THREAD ID=%d\n", thread_id);
917
918
919 #ifndef NAVIT_DEBUG_BAREMETAL
920
921 struct point p_end;
922 struct point p_start;
923
924 p_start.x = x1;
925 p_start.y = y1;
926 p_end.x = x2;
927 p_end.y = y2;
928 update_transformation(global_navit->trans, &p_start, &p_end, NULL);
929 // graphics_draw_drag(this_->gra, NULL);
930 transform_copy(global_navit->trans, global_navit->trans_cursor);
931 global_navit->moved = 1;
932
933 /*
934 struct coord c;
935 struct pcoord pc;
936 p.x = x;
937 p.y = y;
938 transform_reverse(global_navit->trans, &p, &c);
939 pc.x = c.x;
940 pc.y = c.y;
941 pc.pro = transform_get_projection(global_navit->trans);
942 navit_set_position(global_navit, &pc);
943 */
944
945 // dbg(0,"call async java draw -start-\n");
946 if (draw == 1)
947 {
948 navit_draw(global_navit);
949 }
950 else
951 {
952 // if we dont want to draw, then also cancel any drawing that is already in progress!
953 cancel_drawing_global = 1;
954 }
955 // navit_draw_async(global_navit, 1);
956 // dbg(0,"call async java draw --end--\n");
957
958 // remove the "wait" screen
959 //#ifdef HAVE_API_ANDROID
960 // android_return_generic_int(2, 0);
961 //#endif
962
963 #endif
964
965 }
966
967 JNIEXPORT void JNICALL
968 Java_com_zoffcc_applications_zanavi_NavitGraphics_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id)
969 {
970 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
971 dbg(0,"+#+:enter\n");
972 #endif
973
974 #ifndef NAVIT_DEBUG_BAREMETAL
975
976 JNIEnv *jnienv2;
977 jnienv2 = jni_getenv();
978
979 //int thread_id = gettid();
980 //dbg(0, "THREAD ID=%d\n", thread_id);
981
982 //DBG // dbg(0,"enter %p %d %p\n",thiz, delete, (void *)id);
983 //dbg(0,"timeout 1\n");
984 // ICS
985 //if (id != 0)
986 //{
987 // dbg(0,"callback struct=%p %d\n", id, id);
988 callback_call_0((struct callback *) id);
989 //}
990 // ICS
991 //dbg(0,"timeout 2\n");
992
993 /*
994 if (delete)
995 {
996 //dbg(0,"timeout 3\n");
997 // ICS
998 jobject this_global = (*jnienv2)->NewGlobalRef(jnienv2, thiz);
999 //dbg(0,"timeout 3.1\n");
1000 (*jnienv2)->DeleteGlobalRef(jnienv2, this_global);
1001 // ICS
1002 //dbg(0,"timeout 4\n");
1003 }
1004 */
1005 #endif
1006 }
1007
1008 JNIEXPORT void JNICALL
1009 Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id)
1010 {
1011 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1012 dbg(0,"+#+:enter\n");
1013 #endif
1014
1015 //int thread_id = gettid();
1016 // dbg(0, "THREAD ID=%d\n", thread_id);
1017
1018 //DBG // dbg(0,"enter %p %p\n",thiz, (void *)id);
1019 // dbg(0,"idlecall back 1\n");
1020 callback_call_0((struct callback *) id);
1021 // dbg(0,"idlecall back 2\n");
1022 }
1023
1024 JNIEXPORT void JNICALL
1025 Java_com_zoffcc_applications_zanavi_NavitWatch_poll(JNIEnv* env, jobject thiz, int fd, int cond)
1026 {
1027 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1028 dbg(0,"+#+:enter\n");
1029 #endif
1030 struct pollfd pfd;
1031 pfd.fd = fd;
1032 //DBG // dbg(0, "%p poll called for %d %d\n", env, fd, cond);
1033 switch ((enum event_watch_cond) cond)
1034 {
1035 case event_watch_cond_read:
1036 pfd.events = POLLIN;
1037 break;
1038 case event_watch_cond_write:
1039 pfd.events = POLLOUT;
1040 break;
1041 case event_watch_cond_except:
1042 pfd.events = POLLERR;
1043 break;
1044 default:
1045 pfd.events = 0;
1046 }
1047 pfd.revents = 0;
1048 poll(&pfd, 1, -1);
1049 }
1050
1051 JNIEXPORT void JNICALL
1052 Java_com_zoffcc_applications_zanavi_NavitWatch_WatchCallback(JNIEnv* env, jobject thiz, int id)
1053 {
1054 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1055 dbg(0,"+#+:enter\n");
1056 #endif
1057 //DBG // dbg(0, "enter %p %p\n", thiz, (void *) id);
1058 callback_call_0((struct callback *) id);
1059 }
1060
1061 JNIEXPORT void JNICALL
1062 Java_com_zoffcc_applications_zanavi_NavitSensors_SensorCallback(JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z)
1063 {
1064 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1065 dbg(0,"+#+:enter\n");
1066 #endif
1067 // JNIEnv *jnienv2;
1068 // jnienv2 = jni_getenv();
1069
1070 //int thread_id = gettid();
1071 // dbg(0, "THREAD ID=%d\n", thread_id);
1072
1073 //DBG // dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z);
1074 callback_call_4((struct callback *) id, sensor, &x, &y, &z);
1075 }
1076
1077
1078
1079 Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback__XX_real(JNIEnv *env, jobject thiz, double lat, double lon, float speed, float direction, double height, float radius, long gpstime)
1080 {
1081 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1082 dbg(0,"+#+:enter\n");
1083 #endif
1084
1085 #ifndef NAVIT_DEBUG_BAREMETAL
1086
1087 // JNIEnv *jnienv2;
1088 // jnienv2 = jni_getenv();
1089 //int thread_id = gettid();
1090 //dbg(0, "THREAD ID=%d\n", thread_id);
1091
1092 //dbg(0,"VehicleCallback location=%p\n", location);
1093 //+++jobject location2 = (*env)->NewGlobalRef(env, location);
1094 //+++(*env)->DeleteLocalRef(env, location);
1095 //// dbg(0,"location=%p\n", location2);
1096
1097 if ((global_navit) && (global_navit->vehicle) && (global_navit->vehicle->vehicle))
1098 {
1099 vehicle_update_(global_navit->vehicle->vehicle, lat, lon, speed, direction, height, radius, gpstime);
1100 }
1101 else
1102 {
1103 dbg(0, "no vehicle set !!\n");
1104 }
1105
1106 #endif
1107
1108 //dbg(0,"leave\n");
1109
1110 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1111 dbg(0,"+#+:leave\n");
1112 #endif
1113 }
1114
1115
1116 JNIEXPORT void JNICALL
1117 Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv *env, jobject thiz, double lat, double lon, float speed, float direction, double height, float radius, long gpstime)
1118 {
1119 COFFEE_TRY_JNI(env, Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback__XX_real(env, thiz, lat, lon, speed, direction, height, radius, gpstime));
1120 }
1121
1122
1123
1124
1125 void android_return_search_result(struct jni_object *jni_o, char *str)
1126 {
1127 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1128 dbg(0,"+#+:enter\n");
1129 #endif
1130 // dbg(0,"EEnter\n");
1131
1132 // int thread_id = gettid();
1133 // dbg(0, "THREAD ID=%d\n", thread_id);
1134
1135 jstring js2 = NULL;
1136 JNIEnv* env2;
1137 env2 = jni_o->env;
1138 js2 = (*env2)->NewStringUTF(jni_o->env, str);
1139 (*env2)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, js2);
1140 (*env2)->DeleteLocalRef(jni_o->env, js2);
1141 }
1142
1143 void android_return_generic_int(int id, int i)
1144 {
1145 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1146 dbg(0,"+#+:enter\n");
1147 #endif
1148 //DBG // dbg(0,"Enter\n");
1149
1150 // int thread_id = gettid();
1151 // dbg(0, "THREAD ID=%d\n", thread_id);
1152
1153 JNIEnv *jnienv2;
1154 jnienv2 = jni_getenv();
1155
1156
1157 if (NavitGraphicsClass2 == NULL)
1158 {
1159 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
1160 {
1161 NavitGraphicsClass2 = NULL;
1162 return;
1163 }
1164 }
1165 //DBG // dbg(0,"xx1\n");
1166 if (return_generic_int == NULL)
1167 {
1168 android_find_static_method(NavitGraphicsClass2, "return_generic_int", "(II)V", &return_generic_int);
1169 }
1170 //DBG // dbg(0,"xx2\n");
1171 if (return_generic_int == NULL)
1172 {
1173 //DBG // dbg(0, "no method found\n");
1174 return; /* exception thrown */
1175 }
1176 //DBG // dbg(0,"xa1\n");
1177 // -crash- (*jnienv2)->CallVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
1178 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
1179 // -works- (*jnienv2)->CallStaticObjectMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
1180 //DBG // dbg(0,"xa2\n");
1181 }
1182
1183
1184 JNIEXPORT void JNICALL
1185 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList__XX_real(JNIEnv* env, jobject thiz, int id, int partial, jobject str, jobject str_town, jobject str_hn, int search_flags, jobject search_country, jobject latlon, int radius)
1186 {
1187 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1188 dbg(0,"+#+:enter\n");
1189 #endif
1190
1191 int thread_id = gettid();
1192 // dbg(0, "THREAD ID=%d\n", thread_id);
1193
1194 const char *s;
1195 s = (*env)->GetStringUTFChars(env, str, NULL);
1196 ////DBG // dbg(0,"*****string=%s\n",s);
1197
1198
1199 config_get_attr(config, attr_navit, &attr, NULL);
1200 // attr.u.navit
1201
1202 jstring js2 = NULL;
1203 jclass cls_local = (*env)->GetObjectClass(env, thiz);
1204
1205 // ICS ???
1206 jclass cls = (*env)->NewGlobalRef(env, cls_local);
1207 // ICS ???
1208
1209 jmethodID aMethodID = (*env)->GetMethodID(env, cls, "fillStringArray", "(Ljava/lang/String;)V");
1210 if (aMethodID == 0)
1211 {
1212 ////DBG // dbg(0,"**** Unable to get methodID: fillStringArray");
1213 return;
1214 }
1215
1216 if (id)
1217 {
1218 // search for town in variable "s" within current country -> return a list of towns as result
1219 if (id == 1)
1220 {
1221 // unused now!!
1222 }
1223 // new experimental street-index search
1224 else if (id == 2)
1225 {
1226 offline_search_break_searching = 0;
1227
1228 struct jni_object my_jni_object;
1229 my_jni_object.env = env;
1230 my_jni_object.jo = thiz;
1231 my_jni_object.jm = aMethodID;
1232
1233 const char *s_town;
1234 s_town = (*env)->GetStringUTFChars(env, str_town, NULL);
1235 const char *s_hn;
1236 s_hn = (*env)->GetStringUTFChars(env, str_hn, NULL);
1237
1238 search_v2(s, s_town, s_hn, partial, &my_jni_object);
1239
1240 (*env)->ReleaseStringUTFChars(env, str_town, s_town);
1241 (*env)->ReleaseStringUTFChars(env, str_hn, s_hn);
1242
1243 }
1244 // search for street in variable "s" within "search_country" -> return a list of streets as result
1245 // ------- normal search ----------
1246 // ------- normal search ----------
1247 // ------- normal search ----------
1248 // ------- normal search ----------
1249 // ------- normal search ----------
1250 // ------- normal search ----------
1251 else if (id == 29)
1252 {
1253 //struct attr s_attr4;
1254 //struct gui_priv *gp4;
1255 //struct gui_priv gp_24;
1256
1257 offline_search_break_searching = 0;
1258
1259 struct jni_object my_jni_object;
1260 my_jni_object.env = env;
1261 my_jni_object.jo = thiz;
1262 my_jni_object.jm = aMethodID;
1263
1264 //gp4=&gp_24;
1265 //gp4->nav=attr.u.navit;
1266 struct mapset *ms4 = navit_get_mapset(attr.u.navit);
1267 GList *ret = NULL;
1268 int flags = search_flags;
1269 char *search_country_string = (*env)->GetStringUTFChars(env, search_country, NULL);
1270 ret = search_by_address(ret, ms4, s, partial, &my_jni_object, flags, search_country_string);
1271 (*env)->ReleaseStringUTFChars(env, search_country, search_country_string);
1272
1273 // free the memory
1274 g_list_free(ret);
1275 ////DBG // dbg(0,"ret=%p\n",ret);
1276
1277
1278 //if (gp4->sl)
1279 //{
1280 // //search_list_destroy(gp4->sl);
1281 // gp4->sl=NULL;
1282 //}
1283 }
1284 // do a full search in all mapfiles for string in variable "s" -> return a list of streets as result
1285 else if (id == 3)
1286 {
1287 const char *s3;
1288 s3 = (*env)->GetStringUTFChars(env, latlon, NULL);
1289 char parse_str[strlen(s3) + 1];
1290 strcpy(parse_str, s3);
1291 (*env)->ReleaseStringUTFChars(env, latlon, s3);
1292
1293 struct coord_geo g7;
1294 char *p;
1295 char *stopstring;
1296
1297 // lat
1298 p = strtok(parse_str, "#");
1299 g7.lat = strtof(p, &stopstring);
1300 // lon
1301 p = strtok(NULL, "#");
1302 g7.lng = strtof(p, &stopstring);
1303
1304 struct jni_object my_jni_object;
1305 my_jni_object.env = env;
1306 my_jni_object.jo = thiz;
1307 my_jni_object.jm = aMethodID;
1308
1309 offline_search_break_searching = 0;
1310
1311 // search_flags --> is search_order (search at what "order" level)
1312 search_full_world(s, partial, search_flags, &my_jni_object, &g7, radius);
1313 }
1314 }
1315
1316 (*env)->ReleaseStringUTFChars(env, str, s);
1317 }
1318
1319
1320 JNIEXPORT void JNICALL
1321 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, jobject str_town, jobject str_hn, int search_flags, jobject search_country, jobject latlon, int radius)
1322 {
1323 COFFEE_TRY_JNI(env, Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList__XX_real(env, thiz, id, partial, str, str_town, str_hn, search_flags, search_country, latlon, radius));
1324 }
1325
1326 JNIEXPORT jint JNICALL
1327 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackDestinationValid(JNIEnv* env, jobject thiz)
1328 {
1329 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1330 dbg(0,"+#+:enter\n");
1331 #endif
1332 //DBG // dbg(0,"EEnter\n");
1333 config_get_attr(config, attr_navit, &attr, NULL);
1334 // //DBG // dbg(0,"destination_valid=%d\n",attr.u.navit->destination_valid);
1335 jint i = 0;
1336 if (attr.u.navit->route)
1337 {
1338 struct route *r;
1339 r = attr.u.navit->route;
1340 i = r->route_status;
1341 // //DBG // dbg(0,"route_status=%d\n",i);
1342 }
1343 return i;
1344 }
1345
1346 static void map_preview_label_line(struct point *p, int count, char *label, int font_size)
1347 {
1348 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1349 dbg(0,"+#+:enter\n");
1350 #endif
1351 int i, x, y, tl, tlm, th, thm, tlsq, l;
1352 float lsq;
1353 double dx, dy;
1354 struct point p_t;
1355 struct point pb[5];
1356
1357 int len = g_utf8_strlen(label, -1);
1358 int xMin = 0;
1359 int yMin = 0;
1360 int yMax = 13 * font_size / 256;
1361 int xMax = 9 * font_size * len / 256;
1362
1363 ////DBG // dbg(0,"xMax=%d\n", xMax);
1364 ////DBG // dbg(0,"yMax=%d\n", yMax);
1365
1366 pb[0].x = xMin;
1367 pb[0].y = -yMin;
1368 pb[1].x = xMin;
1369 pb[1].y = -yMax;
1370 pb[2].x = xMax;
1371 pb[2].y = -yMax;
1372 pb[3].x = xMax;
1373 pb[3].y = -yMin;
1374
1375 tl = (pb[2].x - pb[0].x);
1376 th = (pb[0].y - pb[1].y);
1377
1378 // calc "tl" text length
1379 // tl=strlen(label)*4;
1380 // calc "th" text height
1381 // th=8;
1382
1383 tlm = tl * 32;
1384 thm = th * 36;
1385 tlsq = (tlm * 0.7) * (tlm * 0.7);
1386
1387 for (i = 0; i < count - 1; i++)
1388 {
1389 dx = p[i + 1].x - p[i].x;
1390 dx *= 32;
1391 dy = p[i + 1].y - p[i].y;
1392 dy *= 32;
1393 lsq = dx * dx + dy * dy;
1394
1395 if (lsq > tlsq)
1396 {
1397 ////DBG // dbg(0,"-------- label=%s\n",label);
1398 ////DBG // dbg(0,"px i=%d py i=%d px i+1=%d py i+1=%d\n",p[i].x,p[i].y,p[i+1].x,p[i+1].y);
1399 ////DBG // dbg(0,"dx=%f dy=%f\n",dx,dy);
1400 l = (int) sqrtf(lsq);
1401 ////DBG // dbg(0,"l=%d lsq=%f\n",l,lsq);
1402 x = p[i].x;
1403 y = p[i].y;
1404 if (dx < 0)
1405 {
1406 dx = -dx;
1407 dy = -dy;
1408 x = p[i + 1].x;
1409 y = p[i + 1].y;
1410 }
1411 x += (l - tlm) * dx / l / 64;
1412 y += (l - tlm) * dy / l / 64;
1413 x -= dy * thm / l / 64;
1414 y += dx * thm / l / 64;
1415 p_t.x = x;
1416 p_t.y = y;
1417
1418 ////DBG // dbg(0,"dx=%f dy=%f\n",dx,dy);
1419 ////DBG // dbg(0,"dx=%d dy=%d\n",(int)dx,(int)dy);
1420 ////DBG // dbg(0,"draw px=%d py=%d\n",p_t.x,p_t.y);
1421 ////DBG // dbg(0,"l=%d\n",l);
1422 ////DBG // dbg(0,"+++++++++++++\n");
1423 // **OLD and wrong** android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, dx*0x10000/l, dy*0x10000/l);
1424 android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, (int) dx, (int) dy);
1425 }
1426 }
1427 }
1428
1429
1430
1431 JNIEXPORT void JNICALL
1432 Java_com_zoffcc_applications_zanavi_NavitGraphics_DrawLowqualMap(JNIEnv* env, jobject thiz, jobject latlonzoom, int width, int height, int font_size, int scale, int sel_range)
1433 {
1434 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1435 dbg(0,"+#+:enter\n");
1436 #endif
1437 // config_get_attr(config, attr_navit, &attr, NULL);
1438
1439 const char *s;
1440 int zoom;
1441 s = (*env)->GetStringUTFChars(env, latlonzoom, NULL);
1442 char parse_str[strlen(s) + 1];
1443 strcpy(parse_str, s);
1444 (*env)->ReleaseStringUTFChars(env, latlonzoom, s);
1445 ////DBG // dbg(0,"*****string=%s\n",s);
1446
1447 // show map preview for (lat#lon#zoom)
1448 struct coord_geo g;
1449 char *p;
1450 char *stopstring;
1451
1452 // lat
1453 p = strtok(parse_str, "#");
1454 g.lat = strtof(p, &stopstring);
1455 // lon
1456 p = strtok(NULL, "#");
1457 g.lng = strtof(p, &stopstring);
1458 // zoom
1459 p = strtok(NULL, "#");
1460 zoom = atoi(p);
1461
1462 ////DBG // dbg(0,"lat=%f\n",g.lat);
1463 ////DBG // dbg(0,"lng=%f\n",g.lng);
1464 ////DBG // dbg(0,"zoom=%d\n",zoom);
1465 ////DBG // dbg(0,"w=%d\n",width);
1466 ////DBG // dbg(0,"h=%d\n",height);
1467
1468 struct coord c;
1469 transform_from_geo(projection_mg, &g, &c);
1470
1471 // struct pcoord pc;
1472 // pc.x=c.x;
1473 // pc.y=c.y;
1474 // pc.pro=projection_mg;
1475
1476
1477 // ----------------------- big draw loop -----------------------
1478 // ----------------------- big draw loop -----------------------
1479 // ----------------------- big draw loop -----------------------
1480 // ----------------------- big draw loop -----------------------
1481 struct item *item;
1482 struct map_rect *mr = NULL;
1483 struct mapset *ms;
1484 struct mapset_handle *msh;
1485 struct map* map = NULL;
1486 struct attr map_name_attr;
1487 struct attr attr;
1488
1489 struct map_selection sel;
1490 const int selection_range = sel_range; // should be something with "width" and "height" i guess ??!!
1491
1492 const int max = 100;
1493 int count;
1494 struct coord *ca = g_alloca(sizeof(struct coord) * max);
1495 struct point *pa = g_alloca(sizeof(struct point) * max);
1496
1497 sel.next = NULL;
1498 sel.order = zoom;
1499 sel.range.min = type_none;
1500 sel.range.max = type_last;
1501 sel.u.c_rect.lu.x = c.x - selection_range;
1502 sel.u.c_rect.lu.y = c.y + selection_range;
1503 sel.u.c_rect.rl.x = c.x + selection_range;
1504 sel.u.c_rect.rl.y = c.y - selection_range;
1505
1506 struct transformation *tr;
1507 tr = transform_dup(global_navit->trans);
1508 struct point p_center;
1509 p_center.x = width / 2;
1510 p_center.y = height / 2;
1511 transform_set_screen_center(tr, &p_center);
1512 transform_set_center(tr, &c);
1513 transform_set_scale(tr, scale);
1514 enum projection pro = transform_get_projection(global_navit->trans_cursor);
1515
1516 // reset cancel flag
1517 global_cancel_preview_map_drawing = 0;
1518
1519 ms = global_navit->mapsets->data;
1520 msh = mapset_open(ms);
1521 while (msh && (map = mapset_next(msh, 0)))
1522 {
1523 if (map_get_attr(map, attr_name, &map_name_attr, NULL))
1524 {
1525 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
1526 {
1527 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0)
1528 {
1529 // its an sdcard map
1530 mr = map_rect_new(map, &sel);
1531 if (mr)
1532 {
1533 while ((item = map_rect_get_item(mr)))
1534 {
1535
1536 if (global_cancel_preview_map_drawing == 1)
1537 {
1538 dbg(0, "global_cancel_preview_map_drawing = 1");
1539 break;
1540 }
1541
1542 count = item_coord_get_within_selection(item, ca, max, &sel);
1543
1544 if (!count)
1545 {
1546 continue;
1547 }
1548
1549 struct attr attr_77;
1550 if (item_attr_get(item, attr_flags, &attr_77))
1551 {
1552 item->flags = attr_77.u.num;
1553 }
1554 else
1555 {
1556 item->flags = 0;
1557 }
1558
1559 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1560
1561 if (item_is_street(*item))
1562 {
1563 android_DrawPreview_polyline(pa, count, 0, item_to_name(item->type));
1564 }
1565
1566 }
1567 map_rect_destroy(mr);
1568 }
1569 }
1570 }
1571 }
1572 }
1573 mapset_close(msh);
1574
1575 // ===============================================
1576
1577 if (global_cancel_preview_map_drawing == 1)
1578 {
1579 dbg(0, "global_cancel_preview_map_drawing = 1");
1580 return;
1581 }
1582
1583
1584 // ===============================================
1585
1586
1587 msh = mapset_open(ms);
1588 while (msh && (map = mapset_next(msh, 0)))
1589 {
1590 if (map_get_attr(map, attr_name, &map_name_attr, NULL))
1591 {
1592 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
1593 {
1594 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0)
1595 {
1596 // its an sdcard map
1597 mr = map_rect_new(map, &sel);
1598 if (mr)
1599 {
1600 while ((item = map_rect_get_item(mr)))
1601 {
1602
1603 if (global_cancel_preview_map_drawing == 1)
1604 {
1605 dbg(0, "global_cancel_preview_map_drawing = 1");
1606 break;
1607 }
1608
1609 count = item_coord_get_within_selection(item, ca, max, &sel);
1610
1611 if (!count)
1612 {
1613 continue;
1614 }
1615
1616 struct attr attr_77;
1617 if (item_attr_get(item, attr_flags, &attr_77))
1618 {
1619 item->flags = attr_77.u.num;
1620 }
1621 else
1622 {
1623 item->flags = 0;
1624 }
1625
1626 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1627
1628 if (item_type_is_area(item->type))
1629 {
1630 android_DrawPreview_polyline(pa, count, 0, item_to_name(item->type));
1631 }
1632
1633 }
1634 map_rect_destroy(mr);
1635 }
1636 }
1637 }
1638 }
1639 }
1640 mapset_close(msh);
1641
1642
1643
1644
1645
1646
1647 /*
1648 enum projection pro2 = transform_get_projection(global_navit->trans_cursor);
1649 struct point pnt;
1650 transform(tr, pro2, &c, &pnt, 1, 0, 0, NULL);
1651 transform_destroy(tr);
1652
1653 */
1654 }
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664 JNIEXPORT void JNICALL
1665 Java_com_zoffcc_applications_zanavi_NavitMapPreviewActivity_DrawMapPreview(JNIEnv* env, jobject thiz, jobject latlonzoom, int width, int height, int font_size, int scale, int sel_range)
1666 {
1667 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1668 dbg(0,"+#+:enter\n");
1669 #endif
1670 // config_get_attr(config, attr_navit, &attr, NULL);
1671
1672 const char *s;
1673 int zoom;
1674 s = (*env)->GetStringUTFChars(env, latlonzoom, NULL);
1675 char parse_str[strlen(s) + 1];
1676 strcpy(parse_str, s);
1677 (*env)->ReleaseStringUTFChars(env, latlonzoom, s);
1678 ////DBG // dbg(0,"*****string=%s\n",s);
1679
1680 // show map preview for (lat#lon#zoom)
1681 struct coord_geo g;
1682 char *p;
1683 char *stopstring;
1684
1685 // lat
1686 p = strtok(parse_str, "#");
1687 g.lat = strtof(p, &stopstring);
1688 // lon
1689 p = strtok(NULL, "#");
1690 g.lng = strtof(p, &stopstring);
1691 // zoom
1692 p = strtok(NULL, "#");
1693 zoom = atoi(p);
1694
1695 ////DBG // dbg(0,"lat=%f\n",g.lat);
1696 ////DBG // dbg(0,"lng=%f\n",g.lng);
1697 ////DBG // dbg(0,"zoom=%d\n",zoom);
1698 ////DBG // dbg(0,"w=%d\n",width);
1699 ////DBG // dbg(0,"h=%d\n",height);
1700
1701 struct coord c;
1702 transform_from_geo(projection_mg, &g, &c);
1703
1704 // struct pcoord pc;
1705 // pc.x=c.x;
1706 // pc.y=c.y;
1707 // pc.pro=projection_mg;
1708
1709
1710 // ----------------------- big draw loop -----------------------
1711 // ----------------------- big draw loop -----------------------
1712 // ----------------------- big draw loop -----------------------
1713 // ----------------------- big draw loop -----------------------
1714 struct item *item;
1715 struct map_rect *mr = NULL;
1716 struct mapset *ms;
1717 struct mapset_handle *msh;
1718 struct map* map = NULL;
1719 struct attr map_name_attr;
1720 struct attr attr;
1721
1722 struct map_selection sel;
1723 const int selection_range = sel_range; // should be something with "width" and "height" i guess ??!!
1724
1725 const int max = 100;
1726 int count;
1727 struct coord *ca = g_alloca(sizeof(struct coord) * max);
1728 struct point *pa = g_alloca(sizeof(struct point) * max);
1729
1730 sel.next = NULL;
1731 sel.order = zoom;
1732 sel.range.min = type_none;
1733 sel.range.max = type_last;
1734 sel.u.c_rect.lu.x = c.x - selection_range;
1735 sel.u.c_rect.lu.y = c.y + selection_range;
1736 sel.u.c_rect.rl.x = c.x + selection_range;
1737 sel.u.c_rect.rl.y = c.y - selection_range;
1738
1739 struct transformation *tr;
1740 tr = transform_dup(global_navit->trans);
1741 struct point p_center;
1742 p_center.x = width / 2;
1743 p_center.y = height / 2;
1744 transform_set_screen_center(tr, &p_center);
1745 transform_set_center(tr, &c);
1746 transform_set_scale(tr, scale);
1747 enum projection pro = transform_get_projection(global_navit->trans_cursor);
1748
1749 ms = global_navit->mapsets->data;
1750 msh = mapset_open(ms);
1751 while (msh && (map = mapset_next(msh, 0)))
1752 {
1753 if (map_get_attr(map, attr_name, &map_name_attr, NULL))
1754 {
1755 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
1756 {
1757 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0)
1758 {
1759 // country borders
1760 // //DBG // dbg(0,"map name=%s",map_name_attr.u.str);
1761 mr = map_rect_new(map, NULL);
1762 if (mr)
1763 {
1764 while ((item = map_rect_get_item(mr)))
1765 {
1766
1767 // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel);
1768 count = item_coord_get_within_selection(item, ca, max, &sel);
1769 if (!count)
1770 {
1771 continue;
1772 }
1773 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1774
1775 // //DBG // dbg(0,"uu %s\n",item_to_name(item->type));
1776
1777 if (item->type == type_border_country)
1778 {
1779 // //DBG // dbg(0,"BB** %s\n",item_to_name(item->type));
1780 android_DrawMapPreview_polyline(pa, count, 2);
1781 }
1782 }
1783 map_rect_destroy(mr);
1784 }
1785 }
1786 else if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0)
1787 {
1788 // its an sdcard map
1789 // //DBG // dbg(0,"map name=%s",map_name_attr.u.str);
1790 mr = map_rect_new(map, &sel);
1791 if (mr)
1792 {
1793 //char *streetname_last=NULL;
1794
1795 while ((item = map_rect_get_item(mr)))
1796 {
1797 int label_count = 0;
1798 char *labels[2];
1799
1800 // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel);
1801 count = item_coord_get_within_selection(item, ca, max, &sel);
1802
1803 // count=item_coord_get_within_selection(item, ca, max, &sel);
1804 // count=item_coord_get(item, ca, item->type < type_line ? 1: max);
1805 if (!count)
1806 {
1807 continue;
1808 }
1809 ////DBG // dbg(0,"count 1=%d\n", count);
1810
1811 if (count == max)
1812 {
1813 ////DBG // dbg(0,"count overflow!!\n");
1814 }
1815
1816 struct attr attr_77;
1817 if (item_attr_get(item, attr_flags, &attr_77))
1818 {
1819 ////DBG // dbg(0,"uuuuuuuuuuuuu %s uuuuu %d\n",item_to_name(item->type), attr_77.u.num);
1820 item->flags = attr_77.u.num;
1821 }
1822 else
1823 {
1824 item->flags = 0;
1825 }
1826
1827 //if (item_is_street(*item))
1828 //{
1829 // int i3;
1830 // for (i3 = 0 ; i3 < count ; i3++)
1831 // {
1832 // if (i3)
1833 // {
1834 // //DBG // dbg(0,"1 x1=%d\n",ca[i3-1].x);
1835 // //DBG // dbg(0,"1 y1=%d\n",ca[i3-1].y);
1836 // //DBG // dbg(0,"1 x2=%d\n",ca[i3].x);
1837 // //DBG // dbg(0,"1 y2=%d\n",ca[i3].y);
1838 // }
1839 // }
1840 //}
1841
1842 count = transform(tr, pro, ca, pa, count, 0, 0, NULL);
1843
1844 ////DBG // dbg(0,"count 2=%d\n", count);
1845
1846 // --- LABEL ---
1847 labels[1] = NULL;
1848 label_count = 0;
1849 if (item_attr_get(item, attr_label, &attr))
1850 {
1851 labels[0] = attr.u.str;
1852 ////DBG // dbg(0,"labels[0]=%s\n",attr.u.str);
1853 if (!label_count)
1854 {
1855 label_count = 2;
1856 }
1857 }
1858 else
1859 {
1860 labels[0] = NULL;
1861 }
1862 // --- LABEL ---
1863
1864 if (item_is_street(*item))
1865 {
1866 //int i3;
1867 //for (i3 = 0 ; i3 < count ; i3++)
1868 //{
1869 // if (i3)
1870 // {
1871 // //DBG // dbg(0,"2 x1=%d\n",pa[i3-1].x);
1872 // //DBG // dbg(0,"2 y1=%d\n",pa[i3-1].y);
1873 // //DBG // dbg(0,"2 x2=%d\n",pa[i3].x);
1874 // //DBG // dbg(0,"2 y2=%d\n",pa[i3].y);
1875 // }
1876 //}
1877 android_DrawMapPreview_polyline(pa, count, 0);
1878 if (labels[0] != NULL)
1879 {
1880 map_preview_label_line(pa, count, labels[0], font_size);
1881 }
1882 }
1883 else if (item_is_district(*item))
1884 {
1885 if (zoom > 6)
1886 {
1887 // //DBG // dbg(0,"xx** %s - %s\n",item_to_name(item->type),labels[0]);
1888 if (count >= 1)
1889 {
1890 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 2, 0x10000, 0);
1891 }
1892 }
1893 }
1894 else if (item_is_town(*item))
1895 {
1896 // //DBG // dbg(0,"yy** %s - %s\n",item_to_name(item->type),labels[0]);
1897 if (count >= 1)
1898 {
1899 android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 3, 0x10000, 0);
1900 }
1901 }
1902
1903 //if (item_is_street(*item))
1904 //{
1905 // if (item_attr_get(item, attr_label, &attr))
1906 // {
1907 // ////DBG // dbg(0,"street1=%s\n",map_convert_string(item->map, attr.u.str));
1908 // if ( (streetname_last==NULL) || (strcmp(streetname_last,attr.u.str) != 0) )
1909 // {
1910 // ////DBG // dbg(0,"street2=%s\n",map_convert_string(item->map, attr.u.str));
1911 // }
1912 // }
1913 //}
1914 }
1915 //g_free(streetname_last);
1916 map_rect_destroy(mr);
1917 }
1918 }
1919 }
1920 }
1921 }
1922 mapset_close(msh);
1923
1924 enum projection pro2 = transform_get_projection(global_navit->trans_cursor);
1925 struct point pnt;
1926 transform(tr, pro2, &c, &pnt, 1, 0, 0, NULL);
1927 transform_destroy(tr);
1928 // ----------------------- big draw loop -----------------------
1929 // ----------------------- big draw loop -----------------------
1930 // ----------------------- big draw loop -----------------------
1931 // ----------------------- big draw loop -----------------------
1932
1933 android_DrawMapPreview_target(pnt.x, pnt.y);
1934 }
1935
1936 void android_DrawMapPreview_target(int x, int y)
1937 {
1938 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1939 dbg(0,"+#+:enter\n");
1940 #endif
1941
1942 JNIEnv *jnienv2;
1943 jnienv2 = jni_getenv();
1944
1945 if (NavitMapPreviewActivityClass == NULL)
1946 {
1947 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
1948 {
1949 NavitMapPreviewActivityClass = NULL;
1950 return;
1951 }
1952 }
1953 if (DrawMapPreview_target == NULL)
1954 {
1955 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_target", "(II)V", &DrawMapPreview_target);
1956 }
1957 if (DrawMapPreview_target == NULL)
1958 {
1959 //DBG // dbg(0, "no method found\n");
1960 return; /* exception thrown */
1961 }
1962 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_target, x, y);
1963 }
1964
1965 void android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy)
1966 {
1967 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1968 dbg(0,"+#+:enter\n");
1969 #endif
1970
1971 JNIEnv *jnienv2;
1972 jnienv2 = jni_getenv();
1973
1974 if (NavitMapPreviewActivityClass == NULL)
1975 {
1976 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
1977 {
1978 NavitMapPreviewActivityClass = NULL;
1979 return;
1980 }
1981 }
1982 if (DrawMapPreview_text == NULL)
1983 {
1984 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_text", "(IILjava/lang/String;III)V", &DrawMapPreview_text);
1985 }
1986 if (DrawMapPreview_text == NULL)
1987 {
1988 //DBG // dbg(0, "no method found\n");
1989 return; /* exception thrown */
1990 }
1991
1992 ////DBG // dbg(0,"** dx=%d,dy=%d\n",dx,dy);
1993
1994 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
1995 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_text, x, y, string1, size, dx, dy);
1996 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
1997 }
1998
1999 void android_DrawMapPreview_polyline(struct point *p, int count, int type)
2000 {
2001 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2002 dbg(0,"+#+:enter\n");
2003 #endif
2004 // type:
2005 // 0 -> normal street
2006 // 2 -> country border
2007
2008 JNIEnv *jnienv2;
2009 jnienv2 = jni_getenv();
2010
2011 if (NavitMapPreviewActivityClass == NULL)
2012 {
2013 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass))
2014 {
2015 NavitMapPreviewActivityClass = NULL;
2016 return;
2017 }
2018 }
2019 if (DrawMapPreview_polyline == NULL)
2020 {
2021 android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_polyline", "(I[I)V", &DrawMapPreview_polyline);
2022 }
2023 if (DrawMapPreview_polyline == NULL)
2024 {
2025 //DBG // dbg(0, "no method found\n");
2026 return; /* exception thrown */
2027 }
2028
2029 jint pc[count * 2];
2030 int i;
2031 jintArray points;
2032 if (count <= 0)
2033 {
2034 return;
2035 }
2036 points = (*jnienv2)->NewIntArray(jnienv2, count * 2);
2037 for (i = 0; i < count; i++)
2038 {
2039 pc[i * 2] = p[i].x;
2040 pc[i * 2 + 1] = p[i].y;
2041 }
2042 (*jnienv2)->SetIntArrayRegion(jnienv2, points, 0, count * 2, pc);
2043 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitMapPreviewActivityClass, DrawMapPreview_polyline, type, points);
2044 (*jnienv2)->DeleteLocalRef(jnienv2, points);
2045 }
2046
2047
2048 void android_DrawPreview_polyline(struct point *p, int count, int type, const char* item_type)
2049 {
2050 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2051 dbg(0,"+#+:enter\n");
2052 #endif
2053 // type:
2054 // 0 -> normal street
2055 // 2 -> country border
2056
2057 JNIEnv *jnienv2;
2058 jnienv2 = jni_getenv();
2059
2060
2061 if (NavitGraphicsClass2 == NULL)
2062 {
2063 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
2064 {
2065 NavitGraphicsClass2 = NULL;
2066 return;
2067 }
2068 }
2069
2070
2071 if (DrawPreview_polyline == NULL)
2072 {
2073 android_find_static_method(NavitGraphicsClass2, "DrawPreview_polyline", "(I[ILjava/lang/String;)V", &DrawPreview_polyline);
2074 }
2075
2076 if (DrawPreview_polyline == NULL)
2077 {
2078 //DBG // dbg(0, "no method found\n");
2079 return; /* exception thrown */
2080 }
2081
2082 jint pc[count * 2];
2083 int i;
2084 jintArray points;
2085 if (count <= 0)
2086 {
2087 return;
2088 }
2089
2090 if (global_cancel_preview_map_drawing == 1)
2091 {
2092 return;
2093 }
2094
2095
2096 points = (*jnienv2)->NewIntArray(jnienv2, count * 2);
2097
2098 for (i = 0; i < count; i++)
2099 {
2100 pc[i * 2] = p[i].x;
2101 pc[i * 2 + 1] = p[i].y;
2102 }
2103
2104 jstring string1;
2105 if (item_type)
2106 {
2107 string1 = (*jnienv2)->NewStringUTF(jnienv2, item_type);
2108 }
2109 else
2110 {
2111 string1 = (*jnienv2)->NewStringUTF(jnienv2, "xx__unknown__xx");
2112 }
2113
2114 (*jnienv2)->SetIntArrayRegion(jnienv2, points, 0, count * 2, pc);
2115 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, DrawPreview_polyline, type, points, string1);
2116 (*jnienv2)->DeleteLocalRef(jnienv2, points);
2117 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
2118 }
2119
2120
2121 JNIEXPORT jobjectArray JNICALL
2122 Java_com_zoffcc_applications_zanavi_NavitGraphics_GetRoadBookItems(JNIEnv *env, jobject thiz, int result_id)
2123 {
2124 jobjectArray ret;
2125 int i;
2126 jclass *string_class = (*env)->FindClass(env, "java/lang/String");
2127
2128 // get roadbook
2129 GList *result = navit_route_export_to_java_string(global_navit, result_id);
2130
2131 if (result == NULL)
2132 {
2133 return NULL;
2134 }
2135
2136
2137 jstring string77 = (*env)->NewStringUTF(env, "");
2138 ret = (jobjectArray)(*env)->NewObjectArray(env, g_list_length(result), string_class, string77);
2139 (*env)->DeleteLocalRef(env, string77);
2140
2141
2142 jstring string88 = (*env)->NewStringUTF(env, "");
2143
2144 GList *result2 = result;
2145 i = 0;
2146 while (result2)
2147 {
2148 char *str = result2->data;
2149
2150 if (str != NULL)
2151 {
2152 jstring string99 = (*env)->NewStringUTF(env, str);
2153 (*env)->SetObjectArrayElement(env, ret, i, string99);
2154 (*env)->DeleteLocalRef(env, string99);
2155 g_free(str);
2156 }
2157 else
2158 {
2159 (*env)->SetObjectArrayElement(env, ret, i, string88);
2160 }
2161 i++;
2162
2163 result2 = g_list_next(result2);
2164 }
2165
2166 g_list_free(result);
2167
2168 (*env)->DeleteLocalRef(env, string88);
2169
2170 return(ret);
2171 }
2172
2173
2174
2175
2176
2177 JNIEXPORT jstring JNICALL
2178 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackGeoCalc(JNIEnv* env, jobject thiz, int i, float a, float b)
2179 {
2180 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2181 dbg(0,"+#+:enter\n");
2182 #endif
2183 // dbg(0,"EEnter i=%d\n", i);
2184
2185
2186 int thread_id = gettid();
2187 // dbg(0, "THREAD ID=%d\n", thread_id);
2188
2189 // const char *result;
2190 gchar *result = NULL;
2191
2192 #ifndef NAVIT_DEBUG_BAREMETAL
2193
2194 if (i == 1)
2195 {
2196 // pixel-on-screen to geo
2197 struct coord_geo g22;
2198 struct coord c22;
2199 struct point p;
2200 p.x = a;
2201 p.y = b;
2202 transform_reverse(global_navit->trans, &p, &c22);
2203 ////DBG // dbg(0,"%f, %f\n",a, b);
2204 ////DBG // dbg(0,"%d, %d\n",p.x, p.y);
2205 transform_to_geo(projection_mg, &c22, &g22);
2206 ////DBG // dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng);
2207 result = g_strdup_printf("%f:%f", g22.lat, g22.lng);
2208 }
2209 else if (i == 2)
2210 {
2211 // geo to pixel-on-screen
2212 struct coord c99;
2213 struct coord_geo g99;
2214 g99.lat = a;
2215 g99.lng = b;
2216 ////DBG // dbg(0,"zzzzz %f, %f\n",a, b);
2217 ////DBG // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
2218 transform_from_geo(projection_mg, &g99, &c99);
2219 ////DBG // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
2220
2221 enum projection pro = transform_get_projection(global_navit->trans_cursor);
2222 struct point pnt;
2223 transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
2224 ////DBG // dbg(0,"x=%d\n",pnt.x);
2225 ////DBG // dbg(0,"y=%d\n",pnt.y);
2226
2227 result = g_strdup_printf("%d:%d", pnt.x, pnt.y);
2228 }
2229 else if (i == 3)
2230 {
2231 // show lat,lng position on screen center
2232 struct coord c99;
2233 struct pcoord pc99;
2234 struct coord_geo g99;
2235 g99.lat = a;
2236 g99.lng = b;
2237 ////DBG // dbg(0,"zzzzz %f, %f\n",a, b);
2238 ////DBG // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
2239 transform_from_geo(projection_mg, &g99, &c99);
2240 ////DBG // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
2241
2242 //enum projection pro=transform_get_projection(global_navit->trans_cursor);
2243 //struct point pnt;
2244 //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
2245 ////DBG // dbg(0,"x=%d\n",pnt.x);
2246 ////DBG // dbg(0,"y=%d\n",pnt.y);
2247 pc99.x = c99.x;
2248 pc99.y = c99.y;
2249 pc99.pro = projection_mg;
2250
2251 navit_set_center(global_navit, &pc99, 0);
2252
2253 result = g_strdup("1:1");
2254 }
2255 else if (i == 4)
2256 {
2257 // return current target (the end point, not waypoints)
2258 struct coord_geo g22;
2259 struct pcoord c22;
2260 struct coord c99;
2261
2262 c22 = global_navit->destination;
2263 c99.x = c22.x;
2264 c99.y = c22.y;
2265
2266 transform_to_geo(projection_mg, &c99, &g22);
2267 result = g_strdup_printf("%f:%f", g22.lat, g22.lng);
2268 }
2269 else if (i == 5)
2270 {
2271 // input: x,y pixel on screen
2272 // output: streetname nearest that position
2273 struct coord c22;
2274 struct point p;
2275 struct pcoord c24;
2276 p.x = a;
2277 p.y = b;
2278 transform_reverse(global_navit->trans, &p, &c22);
2279 c24.x = c22.x;
2280 c24.y = c22.y;
2281 c24.pro = transform_get_projection(global_navit->trans);
2282 result = navit_find_nearest_street(global_navit->mapsets->data, &c24);
2283 }
2284 else if (i == 6)
2285 {
2286 // input: lat, lon
2287 // output: streetname nearest that position
2288 struct coord c22;
2289 struct point p;
2290 struct pcoord c24;
2291 struct coord_geo g99;
2292 g99.lat = a;
2293 g99.lng = b;
2294 transform_from_geo(projection_mg, &g99, &c22);
2295 c24.x = c22.x;
2296 c24.y = c22.y;
2297 c24.pro = transform_get_projection(global_navit->trans);
2298 result = navit_find_nearest_street(global_navit->mapsets->data, &c24);
2299 }
2300 else if (i == 7)
2301 {
2302 // input: x,y pixel on screen
2303 // output: 0xFFFF 0xFFFF\n... -> string that can be used for traffic distortion file
2304 struct coord c22;
2305 struct point p;
2306 struct pcoord c24;
2307 p.x = a;
2308 p.y = b;
2309 transform_reverse(global_navit->trans, &p, &c22);
2310 c24.x = c22.x;
2311 c24.y = c22.y;
2312 c24.pro = transform_get_projection(global_navit->trans);
2313 result = navit_find_nearest_street_coords(global_navit->mapsets->data, &c24);
2314 }
2315 else if (i == 8)
2316 {
2317 // input: x,y pixel on screen
2318 // output: nearest street or housenumber
2319 struct coord c22;
2320 struct point p;
2321 struct pcoord c24;
2322 p.x = a;
2323 p.y = b;
2324 transform_reverse(global_navit->trans, &p, &c22);
2325 c24.x = c22.x;
2326 c24.y = c22.y;
2327 c24.pro = transform_get_projection(global_navit->trans);
2328 result = navit_find_nearest_street_hn(global_navit->mapsets->data, &c24);
2329 }
2330 else if (i == 9)
2331 {
2332 // input: x,y pixel on screen
2333 // output: item dump of nearest item
2334 struct coord c22;
2335 struct point p;
2336 struct pcoord c24;
2337 p.x = a;
2338 p.y = b;
2339 transform_reverse(global_navit->trans, &p, &c22);
2340 c24.x = c22.x;
2341 c24.y = c22.y;
2342 c24.pro = transform_get_projection(global_navit->trans);
2343 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 0);
2344 }
2345 else if (i == 10)
2346 {
2347 // input: x,y pixel on screen
2348 // output: item dump of nearest item (pretty output to show to user)
2349 struct coord c22;
2350 struct point p;
2351 struct pcoord c24;
2352 p.x = a;
2353 p.y = b;
2354 transform_reverse(global_navit->trans, &p, &c22);
2355 c24.x = c22.x;
2356 c24.y = c22.y;
2357 c24.pro = transform_get_projection(global_navit->trans);
2358 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 1);
2359 }
2360 else if (i == 11)
2361 {
2362 // coord to pixel-on-screen
2363 struct coord c99;
2364 c99.x = a;
2365 c99.y = b;
2366 struct point pnt;
2367 transform(global_navit->trans, projection_mg, &c99, &pnt, 1, 0, 0, NULL);
2368 result = g_strdup_printf("%d:%d", pnt.x, pnt.y);
2369 }
2370 // else if (i == 13)
2371 // {
2372 // // get roadbook
2373 // result = navit_route_export_to_java_string(global_navit, NULL, (int)a);
2374 // }
2375 else if (i == 12)
2376 {
2377 // calculate next position in interpolation on route
2378 // return string: lat:lon:direction
2379 // example : 48.62:16.775:45.5
2380
2381 struct route *route2 = NULL;
2382 struct map *route_map2 = NULL;
2383 struct map_rect *mr2 = NULL;
2384 struct item *item2 = NULL;
2385 struct coord pos;
2386 struct coord *pos2;
2387 struct coord c;
2388 struct coord c2;
2389 struct coord ci;
2390 struct coord_geo g99;
2391 struct attr attr;
2392 // struct street_data *sd;
2393 int seg_speed;
2394 int seg_speed_old;
2395 int len;
2396 int slen;
2397 int dx;
2398 int dy;
2399 float dir;
2400 int interval = 1000; // milliseconds
2401 int speed = 50; // km/h
2402
2403
2404 if (global_demo_vehicle == 0)
2405 {
2406 route2 = navit_get_route(global_navit);
2407
2408 if (route2)
2409 {
2410 route_map2 = route_get_map(route2);
2411 }
2412
2413 if (route_map2)
2414 {
2415 mr2 = map_rect_new(route_map2, NULL);
2416 }
2417
2418 if (mr2)
2419 {
2420 item2 = map_rect_get_item(mr2);
2421 }
2422
2423 if (item2 && item2->type == type_route_start)
2424 {
2425 item2 = map_rect_get_item(mr2);
2426 }
2427
2428 if (item2 && item2->type == type_route_start_reverse)
2429 {
2430 item2 = map_rect_get_item(mr2);
2431 }
2432
2433 if (item2 && item_coord_get(item2, &pos, 1))
2434 {
2435 pos2 = tracking_get_pos(global_navit->tracking);
2436 pos.x = pos2->x;
2437 pos.y = pos2->y;
2438
2439 dbg(0,"extrapl:002 posx=%d posy=%d itemtype=%s\n", pos.x, pos.y, item_to_name(item2->type));
2440
2441 seg_speed = speed;
2442 // item_dump_attr_stdout(item2, route_map2);
2443 if (item_attr_get(item2, attr_maxspeed, &attr))
2444 {
2445 dbg(0, "extrapl:002.2 max speed=%d\n", attr.u.num);
2446 seg_speed = attr.u.num;
2447 }
2448 seg_speed_old = seg_speed;
2449
2450 len = (seg_speed * interval / 1000) / 3.6; // distance in meters that we drive in 1 second with "seg_speed" km/h !!
2451
2452 while (item2)
2453 {
2454 if (!item_coord_get(item2, &c, 1))
2455 {
2456 item2 = map_rect_get_item(mr2);
2457
2458 if (item2)
2459 {
2460 dbg(0,"extrapl:004 item type=%s\n", item_to_name(item2->type));
2461
2462 // item_dump_attr_stdout(item2, route_map2);
2463 if (item_attr_get(item2, attr_maxspeed, &attr))
2464 {
2465 dbg(0, "extrapl:004.2 max speed=%d\n", attr.u.num);
2466 seg_speed = attr.u.num;
2467 }
2468 }
2469 continue;
2470 }
2471
2472 slen = transform_distance(projection_mg, &pos, &c); // distance between position and current route coord
2473 dbg(0,"extrapl:004.1 slen=%d len=%d\n", slen, len);
2474
2475 if (slen < len) // need to move along the route some more ...
2476 {
2477 len = len - slen;
2478 dbg(0,"extrapl:005 cx=%d cy=%d len=%d\n", c.x, c.y, len);
2479 // now compensate "len" for maybe other speed on next item
2480 if (seg_speed != seg_speed_old)
2481 {
2482 if ((len > 0) && (seg_speed_old > 0)&&(seg_speed > 0))
2483 {
2484 len = (int)((float)len / (float)seg_speed_old * (float)seg_speed);
2485 dbg(0,"extrapl:005.1 len comp.=%d speed=%d speed old=%d\n", len, seg_speed, seg_speed_old);
2486 }
2487 seg_speed_old = seg_speed;
2488 }
2489
2490 pos = c;
2491 }
2492 else
2493 {
2494 if (item_coord_get(item2, &c2, 1) || map_rect_get_item(mr2))
2495 {
2496 dbg(0,"extrapl:006 c2x=%d c2y=%d\n", c2.x, c2.y);
2497 dbg(0,"extrapl:006 cx=%d cy=%d\n", c.x, c.y);
2498
2499 dx = c.x - pos.x;
2500 dy = c.y - pos.y;
2501 ci.x = pos.x + dx * len / slen;
2502 ci.y = pos.y + dy * len / slen;
2503
2504 dbg(0,"extrapl:006 cix=%d ciy=%d\n", ci.x, ci.y);
2505
2506 dir = (float)transform_get_angle_delta(&pos, &c, 0);
2507 }
2508 else
2509 {
2510 ci.x = pos.x;
2511 ci.y = pos.y;
2512 dir = 0.0f;
2513 dbg(0, "extrapl:destination reached\n");
2514 }
2515
2516 transform_to_geo(projection_mg, &ci, &g99);
2517 dbg(0,"extrapl:099=%f:%f:%f\n", g99.lat, g99.lng, dir);
2518 result = g_strdup_printf("%f:%f:%f", g99.lat, g99.lng, dir);
2519
2520 break;
2521 }
2522 }
2523 }
2524 else
2525 {
2526 result = g_strdup("*ERROR*");
2527 }
2528
2529 if (mr2)
2530 {
2531 map_rect_destroy(mr2);
2532 }
2533 }
2534 else
2535 {
2536 result = g_strdup("*ERROR*");
2537 }
2538 }
2539 else if (i == 14)
2540 {
2541 // return current position
2542 // dbg(0, "PPPOS:2:%f %f", ggggg_lat, ggggg_lon);
2543 result = g_strdup_printf("%f:%f", (float)ggggg_lat, (float)ggggg_lon);
2544 }
2545 else if (i == 15)
2546 {
2547 // show lat,lng position on screen center, without map redraw!
2548 struct coord c99;
2549 struct pcoord pc99;
2550 struct coord_geo g99;
2551 g99.lat = a;
2552 g99.lng = b;
2553 ////DBG // dbg(0,"zzzzz %f, %f\n",a, b);
2554 ////DBG // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng);
2555 transform_from_geo(projection_mg, &g99, &c99);
2556 ////DBG // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng);
2557
2558 //enum projection pro=transform_get_projection(global_navit->trans_cursor);
2559 //struct point pnt;
2560 //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL);
2561 ////DBG // dbg(0,"x=%d\n",pnt.x);
2562 ////DBG // dbg(0,"y=%d\n",pnt.y);
2563 pc99.x = c99.x;
2564 pc99.y = c99.y;
2565 pc99.pro = projection_mg;
2566
2567 navit_set_center_no_draw(global_navit, &pc99, 0);
2568
2569 result = g_strdup("1:1");
2570 }
2571
2572
2573
2574 #else
2575 result = g_strdup("*ERROR*");
2576 #endif
2577
2578 // // dbg(0, "result=%s\n", result);
2579 jstring js = (*env)->NewStringUTF(env, result);
2580
2581 if (result)
2582 {
2583 g_free(result);
2584 }
2585
2586 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2587 dbg(0,"+#+:leave\n");
2588 #endif
2589
2590 return js;
2591 }
2592
2593 JNIEXPORT jstring JNICALL
2594 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackLocalizedString(JNIEnv* env, jobject thiz, jobject str)
2595 {
2596 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2597 dbg(0,"+#+:enter\n");
2598 #endif
2599 // // dbg(0,"EEnter\n");
2600
2601 int thread_id = gettid();
2602 // dbg(0, "THREAD ID=%d\n", thread_id);
2603
2604 const char *s;
2605 const char *localized_str;
2606
2607 s = (*env)->GetStringUTFChars(env, str, NULL);
2608 ////DBG // dbg(0,"*****string=%s\n",s);
2609
2610 localized_str = gettext(s);
2611 ////DBG // dbg(0,"localized string=%s",localized_str);
2612
2613 // jstring dataStringValue = (jstring) localized_str;
2614 jstring js = (*env)->NewStringUTF(env, localized_str);
2615
2616 (*env)->ReleaseStringUTFChars(env, str, s);
2617
2618 return js;
2619 }
2620
2621 JNIEXPORT jint JNICALL
2622 Java_com_zoffcc_applications_zanavi_NavitGraphics_GetThreadId(JNIEnv* env, jobject thiz)
2623 {
2624 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2625 dbg(0,"+#+:enter\n");
2626 #endif
2627
2628 int thread_id = gettid();
2629 // // dbg(0, "THREAD ID=%d\n", thread_id);
2630
2631 jint i = thread_id;
2632 return i;
2633 }
2634
2635 JNIEXPORT void JNICALL
2636 Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackMessageChannelReal(JNIEnv* env, jobject thiz, int i, jobject str2)
2637 {
2638 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2639 dbg(0,"+#+:enter\n");
2640 #endif
2641
2642 __F_START__
2643
2644 int thread_id = gettid();
2645 // dbg(0, "THREAD ID=%d\n", thread_id);
2646
2647 #ifndef NAVIT_DEBUG_BAREMETAL
2648
2649 const char *s;
2650 jobject str = (*env)->NewGlobalRef(env, str2);
2651
2652 config_get_attr(config, attr_navit, &attr, NULL);
2653 // attr.u.navit
2654
2655 //DBG // dbg(0,"c1\n");
2656
2657
2658 if (i)
2659 {
2660 if (i == 1)
2661 {
2662 // zoom in
2663 navit_zoom_in_cursor(global_navit, 2);
2664 // navit_zoom_in_cursor(attr.u.navit, 2);
2665 }
2666 else if (i == 2)
2667 {
2668 // zoom out
2669 navit_zoom_out_cursor(global_navit, 2);
2670 // navit_zoom_out_cursor(attr.u.navit, 2);
2671 }
2672 else if (i == 115)
2673 {
2674 // set test number
2675 s = (*env)->GetStringUTFChars(env, str, NULL);
2676 global_test_number = atoi(s);
2677 (*env)->ReleaseStringUTFChars(env, str, s);
2678 }
2679 else if (i == 114)
2680 {
2681 // set night mode 0|1
2682 s = (*env)->GetStringUTFChars(env, str, NULL);
2683 global_night_mode = atoi(s);
2684 (*env)->ReleaseStringUTFChars(env, str, s);
2685 }
2686 else if (i == 113)
2687 {
2688 // cancel preview map drawing
2689 global_cancel_preview_map_drawing = 1;
2690 }
2691 else if (i == 112)
2692 {
2693 // show maps debug view (show maps on lower zoom levels)
2694 s = (*env)->GetStringUTFChars(env, str, NULL);
2695 global_show_maps_debug_view = atoi(s);
2696 (*env)->ReleaseStringUTFChars(env, str, s);
2697 }
2698 else if (i == 111)
2699 {
2700 // show real gps position on map
2701 s = (*env)->GetStringUTFChars(env, str, NULL);
2702 global_tracking_show_real_gps_pos = atoi(s);
2703 // dbg(0, "show_real_gps_pos=%d\n", global_tracking_show_real_gps_pos);
2704 (*env)->ReleaseStringUTFChars(env, str, s);
2705 }
2706 else if (i == 110)
2707 {
2708 // generic int option CallBack [<option name>:<option value "int">]
2709 s = (*env)->GetStringUTFChars(env, str, NULL);
2710
2711 char *str_copy = strdup(s);
2712 char *option_name = NULL;
2713 char *option_value = NULL;
2714
2715 option_name = strsep(&str_copy, ":");
2716 option_value = strsep(&str_copy, ":");
2717
2718 // dbg(0, "a=%s b=%s\n", option_name, option_value);
2719
2720 /*
2721 street_0,living_street" speed="20" route_weight="20" route_prio_weight="30">
2722 street_1_city" speed="35" route_weight="35" route_prio_weight="30">
2723 track_paved" speed="35" route_weight="35" route_prio_weight="30">
2724 street_2_city,ramp_street_2_city" speed="50" route_weight="50" route_prio_weight="30">
2725 street_3_city,ramp_street_3_city" speed="50" route_weight="50" route_prio_weight="20">
2726 ramp_street_4_city" speed="49" route_weight="49" route_prio_weight="12">
2727 street_4_city" speed="50" route_weight="50" route_prio_weight="11">
2728 highway_city" speed="80" route_weight="80" route_prio_weight="9">
2729 street_1_land" speed="35" route_weight="35" route_prio_weight="30">
2730 street_2_land" speed="50" route_weight="50" route_prio_weight="11">
2731 street_3_land" speed="50" route_weight="50" route_prio_weight="11">
2732 street_4_land" speed="80" route_weight="80" route_prio_weight="11">
2733 street_n_lanes" speed="120" route_weight="120" route_prio_weight="9">
2734 ramp_highway_land" speed="119" route_weight="119" route_prio_weight="10">
2735 highway_land" speed="120" route_weight="120" route_prio_weight="9">
2736 */
2737
2738 struct roadprofile *roadprofile = NULL;
2739 int value_ = 0;
2740
2741 if (strcmp(option_name, "street_1_city#route_prio_weight") == 0)
2742 {
2743 roadprofile = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_1_city);
2744 if (roadprofile)
2745 {
2746 value_ = roadprofile->route_prio_weight;
2747 dbg(0, "VPR:old=%d\n", value_);
2748 roadprofile->route_prio_weight = atoi(option_value);
2749 dbg(0, "VPR:new=%d\n", roadprofile->route_prio_weight);
2750 vehicleprofile_change_roadprofile_attr(global_navit->vehicleprofile, roadprofile, type_street_1_city, roadprofile->route_prio_weight);
2751 }
2752
2753
2754 roadprofile = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_1_city);
2755 if (roadprofile)
2756 {
2757 value_ = roadprofile->route_prio_weight;
2758 dbg(0, "VPR:new2=%d\n", value_);
2759 }
2760 }
2761
2762 // global_level2_announcement = atoi(option_value);
2763
2764 g_free(str_copy);
2765
2766 (*env)->ReleaseStringUTFChars(env, str, s);
2767 }
2768 else if (i == 109)
2769 {
2770 // level 2 announcement seconds
2771 s = (*env)->GetStringUTFChars(env, str, NULL);
2772 global_level2_announcement = (float)atoi(s) / 10.0f;
2773 (*env)->ReleaseStringUTFChars(env, str, s);
2774 }
2775 else if (i == 108)
2776 {
2777 // level 1 announcement seconds
2778 s = (*env)->GetStringUTFChars(env, str, NULL);
2779 global_level1_announcement = (float)atoi(s) / 10.0f;
2780 (*env)->ReleaseStringUTFChars(env, str, s);
2781 }
2782 else if (i == 107)
2783 {
2784 // level 0 announcement seconds
2785 s = (*env)->GetStringUTFChars(env, str, NULL);
2786 global_level0_announcement = (float)atoi(s) / 10.0f;
2787 (*env)->ReleaseStringUTFChars(env, str, s);
2788 }
2789 else if (i == 106)
2790 {
2791 // factor for routing/road speed
2792 s = (*env)->GetStringUTFChars(env, str, NULL);
2793 global_road_speed_factor = (float)atoi(s) / 100.0f;
2794 (*env)->ReleaseStringUTFChars(env, str, s);
2795 }
2796 else if (i == 105)
2797 {
2798 // zoom to specific zoomlevel without redrawing the map!
2799 s = (*env)->GetStringUTFChars(env, str, NULL);
2800 int zoom_level = atoi(s);
2801 navit_zoom_to_scale_no_draw(global_navit, zoom_level);
2802 (*env)->ReleaseStringUTFChars(env, str, s);
2803 }
2804 else if (i == 104)
2805 {
2806 // send OVERSPILL_FACTOR to C-code
2807 s = (*env)->GetStringUTFChars(env, str, NULL);
2808 int value = atoi(s);
2809
2810 global_overspill_factor = (float)((float)value / 100.0f);
2811
2812 (*env)->ReleaseStringUTFChars(env, str, s);
2813 }
2814 else if (i == 103)
2815 {
2816 // draw location of self (car) x% lower than screen center
2817 s = (*env)->GetStringUTFChars(env, str, NULL);
2818 int value = atoi(s);
2819
2820 global_navit->radius = value;
2821
2822 (*env)->ReleaseStringUTFChars(env, str, s);
2823 }
2824 else if (i == 102)
2825 {
2826 // set gpsfix flag
2827 s = (*env)->GetStringUTFChars(env, str, NULL);
2828 int value = atoi(s);
2829
2830 global_has_gpsfix = value;
2831
2832 (*env)->ReleaseStringUTFChars(env, str, s);
2833 }
2834 else if (i == 101)
2835 {
2836 // set demo vehicle flag for tracking
2837 dbg(0, "DEMO VEHICLE* flag set\n");
2838 global_demo_vehicle_short_switch = 1;
2839 }
2840 else if (i == 100)
2841 {
2842 // dump callbacks to log
2843 callback_dump_callbacks();
2844 }
2845 else if (i == 99)
2846 {
2847 // set angle_pref value
2848 if (global_navit->tracking)
2849 {
2850 s = (*env)->GetStringUTFChars(env, str, NULL);
2851 int value = atoi(s);
2852
2853 struct attr attr99;
2854 attr99.type = attr_angle_pref;
2855 attr99.u.num = value;
2856
2857 tracking_set_attr(global_navit->tracking, &attr99);
2858
2859 (*env)->ReleaseStringUTFChars(env, str, s);
2860 }
2861 }
2862 else if (i == 98)
2863 {
2864 // set connected_pref value
2865 if (global_navit->tracking)
2866 {
2867 s = (*env)->GetStringUTFChars(env, str, NULL);
2868 int value = atoi(s);
2869
2870 struct attr attr99;
2871 attr99.type = attr_connected_pref;
2872 attr99.u.num = value;
2873
2874 tracking_set_attr(global_navit->tracking, &attr99);
2875
2876 (*env)->ReleaseStringUTFChars(env, str, s);
2877 }
2878 }
2879 else if (i == 97)
2880 {
2881 // set position to (lat#lon#name)
2882 char *name;
2883 s = (*env)->GetStringUTFChars(env, str, NULL);
2884 char parse_str[strlen(s) + 1];
2885 strcpy(parse_str, s);
2886 (*env)->ReleaseStringUTFChars(env, str, s);
2887
2888 struct coord_geo g;
2889 char *p;
2890 char *stopstring;
2891
2892 // lat
2893 p = strtok(parse_str, "#");
2894 g.lat = strtof(p, &stopstring);
2895 // lon
2896 p = strtok(NULL, "#");
2897 g.lng = strtof(p, &stopstring);
2898 // description
2899 name = strtok(NULL, "#");
2900
2901 ////DBG // dbg(0,"lat=%f\n",g.lat);
2902 ////DBG // dbg(0,"lng=%f\n",g.lng);
2903 ////DBG // dbg(0,"str1=%s\n",name);
2904
2905 struct coord c;
2906 transform_from_geo(projection_mg, &g, &c);
2907
2908 struct pcoord pc;
2909 pc.x = c.x;
2910 pc.y = c.y;
2911 pc.pro = projection_mg;
2912
2913 // set position
2914 navit_set_position(global_navit, &pc);
2915 }
2916 else if (i == 96)
2917 {
2918 // dump route to GPX file
2919 s = (*env)->GetStringUTFChars(env, str, NULL);
2920 if (global_navit->route)
2921 {
2922 if (global_navit->route->destinations)
2923 {
2924 navit_route_export_gpx_to_file(global_navit, s);
2925 }
2926 }
2927 (*env)->ReleaseStringUTFChars(env, str, s);
2928 }
2929 else if (i == 95)
2930 {
2931 // change priority for cycle tracks
2932 if (global_vehicle_profile == 1)
2933 {
2934 int old_value = global_cycle_track_prio;
2935 s = (*env)->GetStringUTFChars(env, str, NULL);
2936 global_cycle_track_prio = atoi(s);
2937
2938 if (old_value != atoi(s))
2939 {
2940 if (global_navit->route)
2941 {
2942 if (global_navit->route->destinations)
2943 {
2944 route_path_update(global_navit->route, 1, 1);
2945 }
2946 }
2947 }
2948
2949 (*env)->ReleaseStringUTFChars(env, str, s);
2950 }
2951 }
2952 else if (i == 94)
2953 {
2954 // change priority for cycle lanes
2955 if (global_vehicle_profile == 1)
2956 {
2957 int old_value = global_cycle_lanes_prio;
2958 s = (*env)->GetStringUTFChars(env, str, NULL);
2959 global_cycle_lanes_prio = atoi(s);
2960
2961 if (old_value != atoi(s))
2962 {
2963 if (global_navit->route)
2964 {
2965 if (global_navit->route->destinations)
2966 {
2967 route_path_update(global_navit->route, 1, 1);
2968 }
2969 }
2970 }
2971
2972 (*env)->ReleaseStringUTFChars(env, str, s);
2973 }
2974 }
2975 else if (i == 93)
2976 {
2977 // change vehicle profile's roadprofile values 003
2978
2979 if (global_vehicle_profile == 1)
2980 {
2981
2982 int old_value = 0;
2983 s = (*env)->GetStringUTFChars(env, str, NULL);
2984
2985 struct roadprofile *rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_3_land);
2986
2987 if (rp)
2988 {
2989 old_value = rp->route_prio_weight;
2990 }
2991
2992 if (rp)
2993 {
2994 rp->route_prio_weight = atoi(s);
2995 }
2996
2997 rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_4_land);
2998 if (rp)
2999 {
3000 rp->route_prio_weight = atoi(s);
3001 }
3002
3003 // calc route new!
3004 if (rp)
3005 {
3006 if (old_value != atoi(s))
3007 {
3008 if (global_navit->route)
3009 {
3010 if (global_navit->route->destinations)
3011 {
3012 route_path_update(global_navit->route, 1, 1);
3013 }
3014 }
3015 }
3016 }
3017
3018 (*env)->ReleaseStringUTFChars(env, str, s);
3019 }
3020
3021 }
3022 else if (i == 92)
3023 {
3024 // change vehicle profile's roadprofile values 002
3025
3026 if (global_vehicle_profile == 1)
3027 {
3028
3029 int old_value = 0;
3030 s = (*env)->GetStringUTFChars(env, str, NULL);
3031
3032 struct roadprofile *rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_3_city);
3033
3034 if (rp)
3035 {
3036 old_value = rp->route_prio_weight;
3037 }
3038
3039 if (rp)
3040 {
3041 rp->route_prio_weight = atoi(s);
3042 }
3043
3044 rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_4_city);
3045 if (rp)
3046 {
3047 rp->route_prio_weight = atoi(s);
3048 }
3049
3050 //rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_ramp);
3051 //if (rp)
3052 //{
3053 // rp->route_prio_weight = atoi(s);
3054 //}
3055
3056 // calc route new!
3057 if (rp)
3058 {
3059 if (old_value != atoi(s))
3060 {
3061 if (global_navit->route)
3062 {
3063 if (global_navit->route->destinations)
3064 {
3065 route_path_update(global_navit->route, 1, 1);
3066 }
3067 }
3068 }
3069 }
3070
3071 (*env)->ReleaseStringUTFChars(env, str, s);
3072 }
3073
3074 }
3075 else if (i == 91)
3076 {
3077 // change vehicle profile's roadprofile values 001
3078
3079 if (global_vehicle_profile == 1)
3080 {
3081
3082 int old_value = 0;
3083 s = (*env)->GetStringUTFChars(env, str, NULL);
3084
3085 struct roadprofile *rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_2_city);
3086
3087 if (rp)
3088 {
3089 old_value = rp->route_prio_weight;
3090 }
3091
3092 if (rp)
3093 {
3094 rp->route_prio_weight = atoi(s);
3095 }
3096
3097 rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_1_land);
3098 if (rp)
3099 {
3100 rp->route_prio_weight = atoi(s);
3101 }
3102
3103 rp = vehicleprofile_get_roadprofile(global_navit->vehicleprofile, type_street_2_land);
3104 if (rp)
3105 {
3106 rp->route_prio_weight = atoi(s);
3107 }
3108
3109 // calc route new!
3110 if (rp)
3111 {
3112 if (old_value != atoi(s))
3113 {
3114 if (global_navit->route)
3115 {
3116 if (global_navit->route->destinations)
3117 {
3118 route_path_update(global_navit->route, 1, 1);
3119 }
3120 }
3121 }
3122 }
3123
3124 (*env)->ReleaseStringUTFChars(env, str, s);
3125
3126 // <roadprofile item_types="street_0,street_1_city,living_street" speed="20" route_weight="20" route_prio_weight="2">
3127 // <roadprofile item_types="street_2_city,street_1_land,street_2_land" speed="15" route_weight="15" route_prio_weight="90">
3128
3129 }
3130
3131 }
3132 else if (i == 90)
3133 {
3134 // set vehicleprofile to value of string s ('car','bike')
3135 s = (*env)->GetStringUTFChars(env, str, NULL);
3136 if (!navit_set_vehicleprofile(global_navit, s))
3137 {
3138 }
3139 else
3140 {
3141 if (!strcmp(s, "car"))
3142 {
3143 global_vehicle_profile = 0; // car
3144
3145 if (global_enhance_cycleway == 1)
3146 {
3147 navit_reset_cycleway(global_navit);
3148 }
3149 }
3150 else if (!strcmp(s, "bike-normal"))
3151 {
3152 global_vehicle_profile = 1; // bicycle
3153
3154 if (global_enhance_cycleway == 0)
3155 {
3156 navit_enhance_cycleway(global_navit);
3157 }
3158 }
3159 else if (!strcmp(s, "bike-avoid-roads"))
3160 {
3161 global_vehicle_profile = 1; // bicycle
3162
3163 if (global_enhance_cycleway == 0)
3164 {
3165 navit_enhance_cycleway(global_navit);
3166 }
3167 }
3168 else if (!strcmp(s, "bike-no-oneway"))
3169 {
3170 global_vehicle_profile = 2; // bicycle no one-way!
3171
3172 if (global_enhance_cycleway == 0)
3173 {
3174 navit_enhance_cycleway(global_navit);
3175 }
3176 }
3177 else
3178 {
3179 global_vehicle_profile = 0; // car
3180
3181 if (global_enhance_cycleway == 1)
3182 {
3183 navit_reset_cycleway(global_navit);
3184 }
3185 }
3186 // dbg(0, "global_vehicle_profile=%d\n", global_vehicle_profile);
3187 }
3188 (*env)->ReleaseStringUTFChars(env, str, s);
3189 }
3190 else if (i == 89)
3191 {
3192 // search this far around street-coord to find potential housenumbers for this street
3193 s = (*env)->GetStringUTFChars(env, str, NULL);
3194 global_search_radius_for_housenumbers = atoi(s);
3195 (*env)->ReleaseStringUTFChars(env, str, s);
3196 }
3197 else if (i == 88)
3198 {
3199 // avoid sharp turns penalty
3200 s = (*env)->GetStringUTFChars(env, str, NULL);
3201 global_avoid_sharp_turns_min_penalty = atoi(s);
3202 (*env)->ReleaseStringUTFChars(env, str, s);
3203 }
3204 else if (i == 87)
3205 {
3206 // avoid sharp turns minimum angle. if turn is harder than this angle then set penalty
3207 s = (*env)->GetStringUTFChars(env, str, NULL);
3208 global_avoid_sharp_turns_min_angle = atoi(s);
3209 (*env)->ReleaseStringUTFChars(env, str, s);
3210 }
3211 else if (i == 86)
3212 {
3213 // avoid sharp turns flag to 0 or 1
3214 s = (*env)->GetStringUTFChars(env, str, NULL);
3215 global_avoid_sharp_turns_flag = atoi(s);
3216 (*env)->ReleaseStringUTFChars(env, str, s);
3217 }
3218 else if (i == 85)
3219 {
3220 // C-linedrawing flag to 0 or 1
3221 s = (*env)->GetStringUTFChars(env, str, NULL);
3222 global_clinedrawing_active = atoi(s);
3223 (*env)->ReleaseStringUTFChars(env, str, s);
3224 }
3225 else if (i == 84)
3226 {
3227 // report data dir
3228 s = (*env)->GetStringUTFChars(env, str, NULL);
3229 navit_data_dir = g_strdup(s);
3230 (*env)->ReleaseStringUTFChars(env, str, s);
3231 }
3232 else if (i == 83)
3233 {
3234 // spill all the index files to log output
3235 spill_index();
3236 }
3237 else if (i == 82)
3238 {
3239 // report share dir
3240 s = (*env)->GetStringUTFChars(env, str, NULL);
3241 navit_share_dir = g_strdup(s);
3242 (*env)->ReleaseStringUTFChars(env, str, s);
3243 }
3244 else if (i == 81)
3245 {
3246 // resize layout items by factor
3247 s = (*env)->GetStringUTFChars(env, str, NULL);
3248 displaylist_shift_for_dpi_value_in_layers(global_navit, (double)(atof(s)));
3249 (*env)->ReleaseStringUTFChars(env, str, s);
3250 }
3251 else if (i == 80)
3252 {
3253 // autozoom flag to 0 or 1
3254 s = (*env)->GetStringUTFChars(env, str, NULL);
3255 global_navit->autozoom_active = atoi(s);
3256 (*env)->ReleaseStringUTFChars(env, str, s);
3257 }
3258 else if (i == 79)
3259 {
3260 // set traffic light delay
3261 s = (*env)->GetStringUTFChars(env, str, NULL);
3262 global_traffic_light_delay = atoi(s);
3263 (*env)->ReleaseStringUTFChars(env, str, s);
3264 }
3265 else if (i == 78)
3266 {
3267 // shift layout "order" values
3268 s = (*env)->GetStringUTFChars(env, str, NULL);
3269 displaylist_shift_order_in_map_layers(global_navit, atoi(s));
3270 (*env)->ReleaseStringUTFChars(env, str, s);
3271 }
3272 else if (i == 77)
3273 {
3274 // do not show route rectangles
3275 global_show_route_rectangles = 0;
3276 }
3277 else if (i == 76)
3278 {
3279 // show route rectangles
3280 global_show_route_rectangles = 1;
3281 }
3282 else if (i == 75)
3283 {
3284 // stop demo vechile
3285 global_stop_demo_vehicle = 1;
3286 }
3287 else if (i == 74)
3288 {
3289 // allow demo vechile to move
3290 global_stop_demo_vehicle = 0;
3291 }
3292 else if (i == 73)
3293 {
3294 // update the route path and route graph (e.g. after setting new roadblocks)
3295 // this destroys the route graph and calcs everything totally new!
3296 if (global_navit->route)
3297 {
3298 if (global_navit->route->destinations)
3299 {
3300 route_path_update(global_navit->route, 1, 1);
3301 }
3302 }
3303 }
3304 else if (i == 72)
3305 {
3306 // update the route path and route graph (e.g. after setting new roadblocks)
3307 // does not update destinations!!!
3308 if (global_navit->route)
3309 {
3310 if (global_navit->route->destinations)
3311 {
3312 route_path_update(global_navit->route, 0, 1);
3313 }
3314 }
3315 }
3316 else if (i == 71)
3317 {
3318 // activate/deactivate "route graph" display
3319 // 0 -> deactivate
3320 // 1 -> activate
3321
3322 // _ms_route_graph
3323 // _ms_navigation
3324 s = (*env)->GetStringUTFChars(env, str, NULL);
3325 navit_map_active_flag(global_navit, atoi(s), "_ms_route_graph");
3326 navit_map_active_flag(global_navit, atoi(s), "_ms_navigation");
3327 (*env)->ReleaseStringUTFChars(env, str, s);
3328 }
3329 else if (i == 70)
3330 {
3331 // allow drawing map
3332 hold_drawing = 0;
3333 }
3334 else if (i == 69)
3335 {
3336 // stop drawing map
3337 hold_drawing = 1;
3338 }
3339 else if (i == 68)
3340 {
3341 // shift "order" by this value (only for drawing objects)
3342 s = (*env)->GetStringUTFChars(env, str, NULL);
3343 shift_order = atoi(s);
3344 (*env)->ReleaseStringUTFChars(env, str, s);
3345 }
3346 else if (i == 67)
3347 {
3348 // disable "multipolygons"
3349 global_draw_multipolygons = 0;
3350 }
3351 else if (i == 66)
3352 {
3353 // enable "multipolygons"
3354 global_draw_multipolygons = 1;
3355 }
3356 else if (i == 65)
3357 {
3358 // draw map async
3359 navit_draw_async(global_navit, 1);
3360 }
3361 else if (i == 64)
3362 {
3363 // draw map
3364 navit_draw(global_navit);
3365 }
3366 else if (i == 63)
3367 {
3368 // enable map drawing
3369 disable_map_drawing = 0;
3370 }
3371 else if (i == 62)
3372 {
3373 // disable map drawing
3374 disable_map_drawing = 1;
3375 }
3376 else if (i == 61)
3377 {
3378 // zoom to specific zoomlevel at given point as center
3379 struct point p;
3380 char *pstr;
3381
3382 s = (*env)->GetStringUTFChars(env, str, NULL);
3383 char parse_str[strlen(s) + 1];
3384 strcpy(parse_str, s);
3385 (*env)->ReleaseStringUTFChars(env, str, s);
3386 // (pixel-x#pixel-y#zoom-level)
3387 // pixel-x
3388 pstr = strtok(parse_str, "#");
3389 p.x = atoi(pstr);
3390 // pixel-y
3391 pstr = strtok(NULL, "#");
3392 p.y = atoi(pstr);
3393 // zoom
3394 pstr = strtok(NULL, "#");
3395 int zoom_level = atoi(pstr);
3396 // now call zoom function
3397 navit_zoom_to_scale_with_center_point(global_navit, zoom_level, &p);
3398 }
3399 else if (i == 60)
3400 {
3401 // disable layer "name"
3402 s = (*env)->GetStringUTFChars(env, str, NULL);
3403 navit_layer_set_active(global_navit, s, 0, 0);
3404 (*env)->ReleaseStringUTFChars(env, str, s);
3405 }
3406 else if (i == 59)
3407 {
3408 // enable layer "name"
3409 s = (*env)->GetStringUTFChars(env, str, NULL);
3410 navit_layer_set_active(global_navit, s, 1, 0);
3411 (*env)->ReleaseStringUTFChars(env, str, s);
3412 }
3413 else if (i == 58)
3414 {
3415 // make street search radius bigger to the factor "s"
3416 s = (*env)->GetStringUTFChars(env, str, NULL);
3417 global_search_street_size_factor = atoi(s);
3418 (*env)->ReleaseStringUTFChars(env, str, s);
3419 }
3420 else if (i == 57)
3421 {
3422 // keep drawing streets as if at "order" level xxx
3423 s = (*env)->GetStringUTFChars(env, str, NULL);
3424 limit_order_corrected = atoi(s);
3425 (*env)->ReleaseStringUTFChars(env, str, s);
3426 }
3427 else if (i == 56)
3428 {
3429 // draw polylines with/without circles at the end
3430 //// dbg(0, "dpf1\n");
3431 s = (*env)->GetStringUTFChars(env, str, NULL);
3432 //// dbg(0, "dpf2\n");
3433 draw_polylines_fast = atoi(s);
3434 //// dbg(0, "dpf=%d\n", draw_polylines_fast);
3435 (*env)->ReleaseStringUTFChars(env, str, s);
3436 }
3437 else if (i == 55)
3438 {
3439 // set cache size for (map-)files
3440 //// dbg(0, "csf1\n");
3441 s = (*env)->GetStringUTFChars(env, str, NULL);
3442 //// dbg(0, "csf2\n");
3443 cache_size_file = atoi(s);
3444 file_cache_init();
3445 // dbg(0, "csf=%d\n", cache_size_file);
3446 (*env)->ReleaseStringUTFChars(env, str, s);
3447 }
3448 else if (i == 54)
3449 {
3450 // speak streetnames
3451 global_speak_streetnames = 1;
3452 }
3453 else if (i == 53)
3454 {
3455 // dont speak streetnames
3456 global_speak_streetnames = 0;
3457 }
3458 else if (i == 52)
3459 {
3460 // switch to demo vehicle
3461
3462 s = (*env)->GetStringUTFChars(env, str, NULL);
3463
3464 dbg(0, "**SWITCH TO:DEMO VEHICLE**\n");
3465 global_demo_vehicle_short_switch = 0;
3466 global_demo_vehicle = 1;
3467
3468 if (global_navit->vehicle)
3469 {
3470 navit_remove_cursors(global_navit);
3471 vehicle_destroy(global_navit->vehicle->vehicle);
3472 global_navit->vehicles = NULL;
3473 global_navit->vehicle = NULL;
3474 }
3475
3476 struct attr parent;
3477 struct attr source;
3478 struct attr active;
3479 struct attr follow;
3480 struct attr speed;
3481 struct attr interval;
3482 struct attr *attrs[6];
3483 parent.type = attr_navit;
3484 parent.u.navit = global_navit;
3485
3486 source.type = attr_source;
3487 source.u.str = "demo://";
3488
3489 active.type = attr_active;
3490 active.u.num = 1;
3491
3492 follow.type = attr_follow;
3493 follow.u.num = 1;
3494
3495 speed.type = attr_speed;
3496
3497 if ((global_vehicle_profile == 1) || (global_vehicle_profile == 2))
3498 {
3499 // for bicycle it's always 27 km/h
3500 speed.u.num = 27;
3501 }
3502 else
3503 {
3504 // should be 45 km/h
3505 speed.u.num = atoi(s);
3506 }
3507
3508 interval.type = attr_interval;
3509 interval.u.num = 1000; // 1 sec.
3510 // interval.u.num = 5000; // 5 sec.
3511
3512 attrs[0] = &source;
3513 attrs[1] = &active;
3514 attrs[2] = &follow;
3515 attrs[3] = &speed;
3516 attrs[4] = &interval;
3517 attrs[5] = NULL;
3518 // attr_source -> source->u.str='demo://'
3519 // <!-- vehicle name="Demo" profilename="car" enabled="no" active="yes" source="demo://" -->
3520 struct vehicle *v;
3521 //DBG // dbg(0, "demo vehicle new start\n");
3522 v = vehicle_new(&parent, attrs);
3523 //DBG // dbg(0, "demo vehicle new end\n");
3524
3525 if (v != NULL)
3526 {
3527 //DBG // dbg(0, "adding demo vehicle\n");
3528 navit_add_vehicle(global_navit, v);
3529 //DBG // dbg(0, "setting cursor\n");
3530 navit_set_cursors(global_navit);
3531
3532 struct attr follow2;
3533 follow2.type = attr_follow;
3534 follow2.u.num = 1;
3535 navit_set_attr(global_navit, &follow2);
3536
3537 // switch "Map follows Vehicle" ON
3538 struct attr attrx;
3539 attrx.type = attr_follow_cursor;
3540 attrx.u.num = 1;
3541 navit_set_attr(global_navit, &attrx);
3542 }
3543 else
3544 {
3545 //DBG // dbg(0, "ERROR adding demo vehicle\n");
3546 }
3547 // **no** navit_set_vehicle(global_navit, global_navit->vehicle);
3548 //DBG // dbg(0, "ready\n");
3549
3550 (*env)->ReleaseStringUTFChars(env, str, s);
3551 }
3552 else if (i == 51)
3553 {
3554 // set position to pixel x,y
3555 //DBG // dbg(0, "sp 1\n");
3556 char *pstr;
3557 struct point p;
3558 struct coord c;
3559 struct pcoord pc;
3560
3561 s = (*env)->GetStringUTFChars(env, str, NULL);
3562 char parse_str[strlen(s) + 1];
3563 strcpy(parse_str, s);
3564 (*env)->ReleaseStringUTFChars(env, str, s);
3565
3566 // (pixel-x#pixel-y)
3567 // pixel-x
3568 pstr = strtok(parse_str, "#");
3569 p.x = atoi(pstr);
3570 // pixel-y
3571 pstr = strtok(NULL, "#");
3572 p.y = atoi(pstr);
3573
3574 //DBG // dbg(0, "sp 2\n");
3575 transform_reverse(global_navit->trans, &p, &c);
3576 //DBG // dbg(0, "sp 3\n");
3577
3578 pc.x = c.x;
3579 pc.y = c.y;
3580 //DBG // dbg(0, "sp 4\n");
3581 pc.pro = transform_get_projection(global_navit->trans);
3582 //DBG // dbg(0, "sp 5\n");
3583
3584 //DBG // dbg(0, "%d %d\n", pc.x, pc.y);
3585 // set position
3586 //DBG // dbg(0, "sp 6\n");
3587 navit_set_position(global_navit, &pc);
3588 //DBG // dbg(0, "ready\n");
3589 }
3590 else if (i == 50)
3591 {
3592 // we request to stop drawing the map
3593 // dbg(0, "DO__DRAW:cancel_drawing_global=1\n");
3594 cancel_drawing_global = 1;
3595 }
3596 else if (i == 47)
3597 {
3598 // change maps data dir
3599 s = (*env)->GetStringUTFChars(env, str, NULL);
3600 navit_maps_dir = g_strdup(s);
3601 (*env)->ReleaseStringUTFChars(env, str, s);
3602 // //DBG // dbg(0,"*****string use=%s\n",navit_maps_dir);
3603 }
3604 else if (i == 46)
3605 {
3606 // stop searching and show results found until now
3607 offline_search_break_searching = 1;
3608 }
3609 else if (i == 45)
3610 {
3611 // filter duplicates in search results
3612 offline_search_filter_duplicates = 1;
3613 }
3614 else if (i == 44)
3615 {
3616 // show duplicates in search results
3617 offline_search_filter_duplicates = 0;
3618 }
3619 else if (i == 43)
3620 {
3621 // routing mode "normal roads"
3622 routing_mode = 1;
3623 }
3624 else if (i == 42)
3625 {
3626 // routing mode "highways"
3627 routing_mode = 0;
3628 }
3629 else if (i == 41)
3630 {
3631 // switch "Map follows Vehicle" OFF
3632 struct attr attrx;
3633 attrx.type = attr_follow_cursor;
3634 attrx.u.num = 0;
3635 navit_set_attr(global_navit, &attrx);
3636 }
3637 else if (i == 40)
3638 {
3639 // switch "Map follows Vehicle" ON
3640 struct attr attrx;
3641 attrx.type = attr_follow_cursor;
3642 attrx.u.num = 1;
3643 navit_set_attr(global_navit, &attrx);
3644 }
3645 else if (i == 39)
3646 {
3647 // switch "Northing" OFF
3648 struct attr attrx;
3649 attrx.type = attr_orientation;
3650 attrx.u.num = 0;
3651 navit_set_attr(global_navit, &attrx);
3652 }
3653 else if (i == 38)
3654 {
3655 // switch "Northing" ON
3656 struct attr attrx;
3657 attrx.type = attr_orientation;
3658 attrx.u.num = 1;
3659 navit_set_attr(global_navit, &attrx);
3660 }
3661 else if (i == 37)
3662 {
3663 // switch "Lock on road" OFF
3664 struct attr attrx;
3665 attrx.type = attr_tracking;
3666 attrx.u.num = 0;
3667 navit_set_attr(global_navit, &attrx);
3668 }
3669 else if (i == 36)
3670 {
3671 // switch "Lock on road" ON
3672 struct attr attrx;
3673 attrx.type = attr_tracking;
3674 attrx.u.num = 1;
3675 navit_set_attr(global_navit, &attrx);
3676 }
3677 else if (i == 35)
3678 {
3679 // announcer voice ON
3680 navit_cmd_announcer_on(global_navit);
3681 }
3682 else if (i == 34)
3683 {
3684 // announcer voice OFF
3685 navit_cmd_announcer_off(global_navit);
3686 }
3687 else if (i == 33)
3688 {
3689 // zoom to specific zoomlevel
3690 s = (*env)->GetStringUTFChars(env, str, NULL);
3691 int zoom_level = atoi(s);
3692 navit_zoom_to_scale(global_navit, zoom_level);
3693 (*env)->ReleaseStringUTFChars(env, str, s);
3694 }
3695 else if (i == 32)
3696 {
3697 // switch to specific 3D pitch
3698 struct attr pitch_attr;
3699 s = (*env)->GetStringUTFChars(env, str, NULL);
3700 pitch_attr.type = attr_pitch;
3701 pitch_attr.u.num = atoi(s);
3702 navit_set_attr(global_navit, &pitch_attr);
3703 (*env)->ReleaseStringUTFChars(env, str, s);
3704 }
3705 else if (i == 31)
3706 {
3707 // switch to 3D
3708 struct attr pitch_attr;
3709 pitch_attr.type = attr_pitch;
3710 pitch_attr.u.num = 30;
3711 navit_set_attr(global_navit, &pitch_attr);
3712 }
3713 else if (i == 30)
3714 {
3715 // switch to 2D
3716 struct attr pitch_attr;
3717 pitch_attr.type = attr_pitch;
3718 pitch_attr.u.num = 0;
3719 navit_set_attr(global_navit, &pitch_attr);
3720 }
3721 // 21 - 25 are used in java, so leave a hole here to make it easier to understand
3722
3723 else if (i == 20)
3724 {
3725 // add all scdard maps
3726 navit_add_all_maps(global_navit);
3727 // get the current vehicle position to the route struct -> set effective starting position for routing
3728 navit_set_vehicle_position_to_screen_center_only_for_route_struct(global_navit);
3729 }
3730 else if (i == 19)
3731 {
3732 // remove all scdard maps
3733 navit_remove_all_maps(global_navit);
3734 }
3735 else if (i == 18)
3736 {
3737 // reload scdard maps
3738 navit_reload_maps(global_navit);
3739 }
3740 else if (i == 17)
3741 {
3742 // zoom to route
3743 navit_zoom_to_route(global_navit, 0);
3744
3745 // return new zoom level to android
3746 long scale = transform_get_scale(global_navit->trans);
3747 dbg(0, "A:new scale=%lld\n", scale);
3748 android_return_generic_int(3, (int) scale);
3749 }
3750 else if (i == 16)
3751 {
3752 // use imperial units
3753 global_navit->imperial = 1;
3754 }
3755 else if (i == 15)
3756 {
3757 // use metric units
3758 global_navit->imperial = 0;
3759 }
3760 else if (i == 14)
3761 {
3762 // draw location of self (car) in the screen center
3763 global_navit->radius = 0;
3764 }
3765 else if (i == 13)
3766 {
3767 // draw location of self (car) 30% lower than screen center
3768 global_navit->radius = 30;
3769 }
3770 else if (i == 12)
3771 {
3772 // draw map only at speeds higher than 5 km/h
3773 struct attr static_speed_attr;
3774 static_speed_attr.type = attr_static_speed;
3775 static_speed_attr.u.num = 5;
3776 vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr);
3777 }
3778 else if (i == 11)
3779 {
3780 // allow redraw map at ZERO speed
3781 struct attr static_speed_attr;
3782 static_speed_attr.type = attr_static_speed;
3783 static_speed_attr.u.num = 0;
3784 vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr);
3785 }
3786 else if (i == 10)
3787 {
3788 // allow internal GUI
3789 allow_gui_internal = 1;
3790 }
3791 else if (i == 9)
3792 {
3793 // disable internal GUI
3794 allow_gui_internal = 0;
3795 }
3796 else if (i == 8)
3797 {
3798 // zoom to zoomlevel
3799 //DBG // dbg(0,"-8- a\n");
3800 navit_zoom_to_scale(global_navit, 524288);
3801 //DBG // dbg(0,"-8- b\n");
3802 }
3803 else if (i == 7)
3804 {
3805 // stop navigation
3806 if (attr.u.navit->destination_valid != 0)
3807 {
3808 navit_set_destination(&attr.u.navit->self, NULL, NULL, 0);
3809 #ifdef DEBUG_GLIB_MEM_FUNCTIONS
3810 g_mem_profile();
3811 #endif
3812 }
3813 }
3814 else if (i == 6)
3815 {
3816 // not used now!
3817 }
3818 else if (i == 5)
3819 {
3820 // toggle layer on/off
3821 s = (*env)->GetStringUTFChars(env, str, NULL);
3822 navit_layer_toggle_active(global_navit, s, 1);
3823 (*env)->ReleaseStringUTFChars(env, str, s);
3824 }
3825 else if (i == 49)
3826 {
3827 // add waypoint at pixel x,y on screen
3828
3829 char *pstr;
3830 struct point p;
3831 struct coord c;
3832 struct pcoord pc;
3833
3834 s = (*env)->GetStringUTFChars(env, str, NULL);
3835 char parse_str[strlen(s) + 1];
3836 strcpy(parse_str, s);
3837 (*env)->ReleaseStringUTFChars(env, str, s);
3838
3839 // add waypoint (pixel-x#pixel-y)
3840 // pixel-x
3841 pstr = strtok(parse_str, "#");
3842 p.x = atoi(pstr);
3843 // pixel-y
3844 pstr = strtok(NULL, "#");
3845 p.y = atoi(pstr);
3846
3847 transform_reverse(global_navit->trans, &p, &c);
3848
3849 pc.x = c.x;
3850 pc.y = c.y;
3851 pc.pro = transform_get_projection(global_navit->trans);
3852
3853 // append new waypoint to navigation
3854 navit_add_waypoint_to_route(global_navit, &pc, parse_str, 1);
3855 }
3856 else if (i == 4)
3857 {
3858 // set destination to pixel x,y on screen
3859
3860 char *pstr;
3861 struct point p;
3862 struct coord c;
3863 struct pcoord pc;
3864
3865 s = (*env)->GetStringUTFChars(env, str, NULL);
3866 char parse_str[strlen(s) + 1];
3867 strcpy(parse_str, s);
3868 (*env)->ReleaseStringUTFChars(env, str, s);
3869
3870 // set destination to (pixel-x#pixel-y)
3871 // pixel-x
3872 pstr = strtok(parse_str, "#");
3873 p.x = atoi(pstr);
3874 // pixel-y
3875 pstr = strtok(NULL, "#");
3876 p.y = atoi(pstr);
3877
3878 transform_reverse(global_navit->trans, &p, &c);
3879
3880 pc.x = c.x;
3881 pc.y = c.y;
3882 pc.pro = transform_get_projection(global_navit->trans);
3883
3884 // start navigation asynchronous
3885 navit_set_destination(global_navit, &pc, parse_str, 1);
3886 }
3887 else if (i == 55548)
3888 {
3889 // append waypoint at lat, lng
3890
3891 char *name;
3892 s = (*env)->GetStringUTFChars(env, str, NULL);
3893 char parse_str[strlen(s) + 1];
3894 strcpy(parse_str, s);
3895 (*env)->ReleaseStringUTFChars(env, str, s);
3896
3897 // waypoint (lat#lon#title)
3898 struct coord_geo g;
3899 char *p;
3900 char *stopstring;
3901
3902 // lat
3903 p = strtok(parse_str, "#");
3904 g.lat = strtof(p, &stopstring);
3905 // lon
3906 p = strtok(NULL, "#");
3907 g.lng = strtof(p, &stopstring);
3908 // description
3909 name = strtok(NULL, "#");
3910
3911 ////DBG // dbg(0,"lat=%f\n",g.lat);
3912 ////DBG // dbg(0,"lng=%f\n",g.lng);
3913 ////DBG // dbg(0,"str1=%s\n",name);
3914
3915 struct coord c;
3916 transform_from_geo(projection_mg, &g, &c);
3917
3918 struct pcoord pc;
3919 pc.x = c.x;
3920 pc.y = c.y;
3921 pc.pro = projection_mg;
3922
3923 if (global_navit->destination_valid == 1)
3924 {
3925 route_add_destination_no_calc(global_navit->route, &pc, 1);
3926
3927 global_navit->destination = pc;
3928 global_navit->destination_valid = 1;
3929 }
3930 else
3931 {
3932 route_set_destination_no_calc(global_navit->route, &pc, 1);
3933 }
3934 }
3935 else if (i == 55598)
3936 {
3937 s = (*env)->GetStringUTFChars(env, str, NULL);
3938 int value = atoi(s);
3939
3940 global_routing_engine = value;
3941
3942 (*env)->ReleaseStringUTFChars(env, str, s);
3943 }
3944 else if (i == 55599)
3945 {
3946 route_after_destination_start_calc(global_navit->route, 1);
3947 }
3948 else if (i == 48)
3949 {
3950 // append waypoint at lat, lng
3951
3952 char *name;
3953 s = (*env)->GetStringUTFChars(env, str, NULL);
3954 char parse_str[strlen(s) + 1];
3955 strcpy(parse_str, s);
3956 (*env)->ReleaseStringUTFChars(env, str, s);
3957
3958 // waypoint (lat#lon#title)
3959 struct coord_geo g;
3960 char *p;
3961 char *stopstring;
3962
3963 // lat
3964 p = strtok(parse_str, "#");
3965 g.lat = strtof(p, &stopstring);
3966 // lon
3967 p = strtok(NULL, "#");
3968 g.lng = strtof(p, &stopstring);
3969 // description
3970 name = strtok(NULL, "#");
3971
3972 ////DBG // dbg(0,"lat=%f\n",g.lat);
3973 ////DBG // dbg(0,"lng=%f\n",g.lng);
3974 ////DBG // dbg(0,"str1=%s\n",name);
3975
3976 struct coord c;
3977 transform_from_geo(projection_mg, &g, &c);
3978
3979 struct pcoord pc;
3980 pc.x = c.x;
3981 pc.y = c.y;
3982 pc.pro = projection_mg;
3983
3984 // append new waypoint to navigation
3985 navit_add_waypoint_to_route(global_navit, &pc, name, 1);
3986 }
3987 else if (i == 55503)
3988 {
3989
3990 // set destination to lat, lng
3991
3992 char *name;
3993 s = (*env)->GetStringUTFChars(env, str, NULL);
3994 char parse_str[strlen(s) + 1];
3995 strcpy(parse_str, s);
3996 (*env)->ReleaseStringUTFChars(env, str, s);
3997 ////DBG // dbg(0,"*****string=%s\n",s);
3998
3999 // set destination to (lat#lon#title)
4000 struct coord_geo g;
4001 char *p;
4002 char *stopstring;
4003
4004 // lat
4005 p = strtok(parse_str, "#");
4006 g.lat = strtof(p, &stopstring);
4007 // lon
4008 p = strtok(NULL, "#");
4009 g.lng = strtof(p, &stopstring);
4010 // description
4011 name = strtok(NULL, "#");
4012
4013 ////DBG // dbg(0,"lat=%f\n",g.lat);
4014 ////DBG // dbg(0,"lng=%f\n",g.lng);
4015 ////DBG // dbg(0,"str1=%s\n",name);
4016
4017 struct coord c;
4018 transform_from_geo(projection_mg, &g, &c);
4019
4020 struct pcoord pc;
4021 pc.x = c.x;
4022 pc.y = c.y;
4023 pc.pro = projection_mg;
4024
4025 global_navit->destination = pc;
4026 global_navit->destination_valid = 1;
4027
4028 if (global_navit->route)
4029 {
4030 route_set_destination_no_calc(global_navit->route, &pc, 1);
4031 }
4032 }
4033 else if (i == 3)
4034 {
4035 // set destination to lat, lng
4036
4037 char *name;
4038 s = (*env)->GetStringUTFChars(env, str, NULL);
4039 char parse_str[strlen(s) + 1];
4040 strcpy(parse_str, s);
4041 (*env)->ReleaseStringUTFChars(env, str, s);
4042 ////DBG // dbg(0,"*****string=%s\n",s);
4043
4044 // set destination to (lat#lon#title)
4045 struct coord_geo g;
4046 char *p;
4047 char *stopstring;
4048
4049 // lat
4050 p = strtok(parse_str, "#");
4051 g.lat = strtof(p, &stopstring);
4052 // lon
4053 p = strtok(NULL, "#");
4054 g.lng = strtof(p, &stopstring);
4055 // description
4056 name = strtok(NULL, "#");
4057
4058 ////DBG // dbg(0,"lat=%f\n",g.lat);
4059 ////DBG // dbg(0,"lng=%f\n",g.lng);
4060 ////DBG // dbg(0,"str1=%s\n",name);
4061
4062 struct coord c;
4063 transform_from_geo(projection_mg, &g, &c);
4064
4065 struct pcoord pc;
4066 pc.x = c.x;
4067 pc.y = c.y;
4068 pc.pro = projection_mg;
4069
4070 // start navigation asynchronous
4071 navit_set_destination(global_navit, &pc, name, 1);
4072
4073 }
4074 }
4075
4076 (*env)->DeleteGlobalRef(env, str);
4077 str = NULL;
4078
4079 // dbg(0,"leave %d\n",i);
4080
4081 #endif
4082
4083 __F_END__
4084
4085 }
4086
4087 void android_send_generic_text(int id, char *text)
4088 {
4089 #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4090 dbg(0,"+#+:enter\n");
4091 #endif
4092 //DBG // dbg(0,"Enter\n");
4093
4094 if (NavitGraphicsClass2 == NULL)
4095 {
4096 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4097 {
4098 NavitGraphicsClass2 = NULL;
4099 return;
4100 }
4101 }
4102 //DBG // dbg(0,"x1\n");
4103 if (send_generic_text == NULL)
4104 {
4105 android_find_static_method(NavitGraphicsClass2, "send_generic_text", "(ILjava/lang/String;)V", &send_generic_text);
4106 }
4107 //DBG // dbg(0,"x2\n");
4108 if (send_generic_text == NULL)
4109 {
4110 //DBG // dbg(0, "no method found\n");
4111 return; /* exception thrown */
4112 }
4113 //DBG // dbg(0,"x3\n");
4114
4115 JNIEnv *jnienv2;
4116 jnienv2 = jni_getenv();
4117
4118 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
4119 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, send_generic_text, id, string1);
4120 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
4121
4122 // // dbg(0,"leave\n");
4123 }
4124
4125 void send_osd_values(char *id, char *text1, char *text2, char *text3, int i1, int i2, int i3, int i4, float f1, float f2, float f3)
4126 {
4127 //DBG // dbg(0,"EEnter\n");
4128 JNIEnv *jnienv2;
4129 jnienv2 = jni_getenv();
4130
4131 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, id);
4132 jstring string2 = (*jnienv2)->NewStringUTF(jnienv2, text1);
4133 jstring string3 = (*jnienv2)->NewStringUTF(jnienv2, text2);
4134 jstring string4 = (*jnienv2)->NewStringUTF(jnienv2, text3);
4135
4136 // static
4137 if (NavitGraphicsClass2 == NULL)
4138 {
4139 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4140 {
4141 NavitGraphicsClass2 = NULL;
4142 return;
4143 }
4144 }
4145
4146 if (NavitGraphics_send_osd_values2 == NULL)
4147 {
4148 if (!android_find_static_method(NavitGraphicsClass2, "send_osd_values", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIFFF)V", &NavitGraphics_send_osd_values2))
4149 {
4150 return;
4151 }
4152 }
4153
4154 // static
4155 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_send_osd_values2, string1, string2, string3, string4, i1, i2, i3, i4, f1, f2, f3);
4156
4157 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
4158 (*jnienv2)->DeleteLocalRef(jnienv2, string2);
4159 (*jnienv2)->DeleteLocalRef(jnienv2, string3);
4160 (*jnienv2)->DeleteLocalRef(jnienv2, string4);
4161 }
4162
4163 void set_vehicle_values_to_java(int x, int y, int angle, int speed)
4164 {
4165 //DBG // dbg(0,"EEnter\n");
4166 JNIEnv *jnienv2;
4167 jnienv2 = jni_getenv();
4168
4169 //int thread_id = gettid();
4170 //dbg(0, "THREAD ID=%d\n", thread_id);
4171
4172 if (NavitGraphicsClass2 == NULL)
4173 {
4174 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4175 {
4176 NavitGraphicsClass2 = NULL;
4177 return;
4178 }
4179 }
4180
4181 if (NavitGraphics_set_vehicle_values2 == NULL)
4182 {
4183 if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values", "(IIII)V", &NavitGraphics_set_vehicle_values2))
4184 {
4185 return;
4186 }
4187 }
4188
4189 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values2, x, y, angle, speed);
4190 }
4191
4192 void set_vehicle_values_to_java_delta(int dx, int dy, int dangle, int dzoom, int l_old, int l_new)
4193 {
4194 JNIEnv *jnienv2;
4195 jnienv2 = jni_getenv();
4196
4197 //int thread_id = gettid();
4198 //dbg(0, "THREAD ID=%d\n", thread_id);
4199
4200 if (NavitGraphicsClass2 == NULL)
4201 {
4202 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4203 {
4204 NavitGraphicsClass2 = NULL;
4205 return;
4206 }
4207 }
4208
4209 if (NavitGraphics_set_vehicle_values3 == NULL)
4210 {
4211 if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values_delta", "(IIIIII)V", &NavitGraphics_set_vehicle_values3))
4212 {
4213 return;
4214 }
4215 }
4216
4217 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values3, dx, dy, dangle, dzoom, l_old, l_new);
4218 }
4219
4220 void send_route_rect_to_java(int x1, int y1, int x2, int y2, int order)
4221 {
4222 JNIEnv *jnienv2;
4223 jnienv2 = jni_getenv();
4224
4225 //int thread_id = gettid();
4226 //dbg(0, "THREAD ID=%d\n", thread_id);
4227
4228 if (NavitGraphicsClass2 == NULL)
4229 {
4230 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4231 {
4232 NavitGraphicsClass2 = NULL;
4233 return;
4234 }
4235 }
4236
4237 if (NavitGraphics_send_route_rect_to_java == NULL)
4238 {
4239 if (!android_find_static_method(NavitGraphicsClass2, "send_route_rect_to_java", "(IIIII)V", &NavitGraphics_send_route_rect_to_java))
4240 {
4241 return;
4242 }
4243 }
4244
4245 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_send_route_rect_to_java, x1, y1, x2, y2, order);
4246 }
4247
4248 void send_alert_to_java(int id, const char *text)
4249 {
4250 JNIEnv *jnienv2;
4251 jnienv2 = jni_getenv();
4252
4253 if (NavitGraphicsClass2 == NULL)
4254 {
4255 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
4256 {
4257 NavitGraphicsClass2 = NULL;
4258 return;
4259 }
4260 }
4261
4262 if (NavitGraphics_alter_missing_icon == NULL)
4263 {
4264 if (!android_find_static_method(NavitGraphicsClass2, "send_alert_to_java", "(ILjava/lang/String;)V", &NavitGraphics_alter_missing_icon))
4265 {
4266 return;
4267 }
4268 }
4269
4270 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
4271 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_alter_missing_icon, id, string1);
4272 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
4273 }
4274

   
Visit the ZANavi Wiki