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