|
|
1 | /** |
|
|
2 | * ZANavi, Zoff Android Navigation system. |
|
|
3 | * Copyright (C) 2011-2012 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 | |
1 | #include <stdlib.h> |
20 | #include <stdlib.h> |
2 | #include <string.h> |
21 | #include <string.h> |
3 | #include <poll.h> |
22 | #include <poll.h> |
4 | #include <glib.h> |
23 | #include <glib.h> |
5 | #include "android.h" |
24 | #include "android.h" |
… | |
… | |
16 | #include "color.h" |
35 | #include "color.h" |
17 | #include "types.h" |
36 | #include "types.h" |
18 | #include "search.h" |
37 | #include "search.h" |
19 | #include "start_real.h" |
38 | #include "start_real.h" |
20 | #include "route.h" |
39 | #include "route.h" |
|
|
40 | #include "file.h" |
21 | |
41 | |
22 | // #include "layout.h" |
42 | // #include "layout.h" |
23 | |
43 | |
24 | JNIEnv *jnienv; |
44 | JNIEnv *jnienv; |
25 | jobject *android_activity; |
45 | jobject *android_activity; |
26 | struct callback_list *android_activity_cbl; |
46 | struct callback_list *android_activity_cbl; |
27 | int android_version; |
47 | int android_version; |
28 | |
48 | |
29 | jclass NavitGraphicsClass2=NULL; |
49 | jclass NavitGraphicsClass2 = NULL; |
30 | jmethodID return_generic_int; |
50 | jmethodID return_generic_int; |
|
|
51 | jmethodID send_generic_text; |
31 | jclass NavitMapPreviewActivityClass=NULL; |
52 | jclass NavitMapPreviewActivityClass = NULL; |
32 | jmethodID DrawMapPreview_target; |
53 | jmethodID DrawMapPreview_target; |
33 | jmethodID DrawMapPreview_polyline=NULL; |
54 | jmethodID DrawMapPreview_polyline = NULL; |
34 | jmethodID DrawMapPreview_text=NULL; |
55 | jmethodID DrawMapPreview_text = NULL; |
35 | |
56 | |
36 | struct attr attr; |
57 | struct attr attr; |
37 | |
58 | |
38 | struct config { |
59 | struct config |
|
|
60 | { |
39 | struct attr **attrs; |
61 | struct attr **attrs; |
40 | struct callback_list *cbl; |
62 | struct callback_list *cbl; |
41 | } *config; |
63 | }*config; |
42 | |
64 | |
43 | |
|
|
44 | struct gui_config_settings { |
65 | struct gui_config_settings |
|
|
66 | { |
45 | int dummy; |
67 | int dummy; |
46 | }; |
68 | }; |
47 | |
69 | |
48 | struct gui_internal_data { |
70 | struct gui_internal_data |
|
|
71 | { |
49 | int dummy; |
72 | int dummy; |
50 | }; |
73 | }; |
51 | |
74 | |
52 | struct route_data { |
75 | struct route_data |
|
|
76 | { |
53 | int dummy; |
77 | int dummy; |
54 | }; |
78 | }; |
55 | |
79 | |
56 | struct widget { |
80 | struct widget |
|
|
81 | { |
57 | int dummy; |
82 | int dummy; |
58 | }; |
83 | }; |
59 | |
84 | |
60 | struct gui_priv { |
85 | struct gui_priv |
|
|
86 | { |
61 | struct navit *nav; |
87 | struct navit *nav; |
62 | struct attr self; |
88 | struct attr self; |
63 | struct window *win; |
89 | struct window *win; |
64 | struct graphics *gra; |
90 | struct graphics *gra; |
65 | struct graphics_gc *background; |
91 | struct graphics_gc *background; |
… | |
… | |
89 | int pressed; |
115 | int pressed; |
90 | struct widget *widgets; |
116 | struct widget *widgets; |
91 | int widgets_count; |
117 | int widgets_count; |
92 | int redraw; |
118 | int redraw; |
93 | struct widget root; |
119 | struct widget root; |
94 | struct widget *highlighted,*editable; |
120 | struct widget *highlighted, *editable; |
95 | struct widget *highlighted_menu; |
121 | struct widget *highlighted_menu; |
96 | int clickp_valid, vehicle_valid; |
122 | int clickp_valid, vehicle_valid; |
97 | struct pcoord clickp, vehiclep; |
123 | struct pcoord clickp, vehiclep; |
98 | struct attr *click_coord_geo, *position_coord_geo; |
124 | struct attr *click_coord_geo, *position_coord_geo; |
99 | struct search_list *sl; |
125 | struct search_list *sl; |
… | |
… | |
106 | int keyboard_required; |
132 | int keyboard_required; |
107 | /** |
133 | /** |
108 | * The setting information read from the configuration file. |
134 | * The setting information read from the configuration file. |
109 | * values of -1 indicate no value was specified in the config file. |
135 | * values of -1 indicate no value was specified in the config file. |
110 | */ |
136 | */ |
111 | struct gui_config_settings config; |
137 | struct gui_config_settings config; |
112 | struct event_idle *idle; |
138 | struct event_idle *idle; |
113 | struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback; |
139 | struct callback *motion_cb, *button_cb, *resize_cb, *keypress_cb, *window_closed_cb, *idle_cb, *motion_timeout_callback; |
114 | struct event_timeout *motion_timeout_event; |
140 | struct event_timeout *motion_timeout_event; |
115 | struct point current; |
141 | struct point current; |
116 | |
142 | |
117 | struct callback * vehicle_cb; |
143 | struct callback * vehicle_cb; |
118 | /** |
144 | /** |
119 | * Stores information about the route. |
145 | * Stores information about the route. |
120 | */ |
146 | */ |
121 | struct route_data route_data; |
147 | struct route_data route_data; |
122 | |
148 | |
123 | struct gui_internal_data data; |
149 | struct gui_internal_data data; |
124 | struct callback_list *cbl; |
150 | struct callback_list *cbl; |
125 | int flags; |
151 | int flags; |
126 | int cols; |
152 | int cols; |
127 | struct attr osd_configuration; |
153 | struct attr osd_configuration; |
128 | int pitch; |
154 | int pitch; |
129 | int flags_town,flags_street,flags_house_number; |
155 | int flags_town, flags_street, flags_house_number; |
130 | int radius; |
156 | int radius; |
131 | /* html */ |
157 | /* html */ |
132 | char *html_text; |
158 | char *html_text; |
133 | int html_depth; |
159 | int html_depth; |
134 | struct widget *html_container; |
160 | struct widget *html_container; |
135 | int html_skip; |
161 | int html_skip; |
136 | char *html_anchor; |
162 | char *html_anchor; |
137 | char *href; |
163 | char *href; |
138 | int html_anchor_found; |
164 | int html_anchor_found; |
139 | struct form *form; |
165 | struct form *form; |
140 | struct html { |
166 | struct html |
|
|
167 | { |
141 | int skip; |
168 | int skip; |
142 | enum html_tag { |
169 | enum html_tag |
143 | html_tag_none, |
170 | { |
144 | html_tag_a, |
171 | 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, |
145 | html_tag_h1, |
|
|
146 | html_tag_html, |
|
|
147 | html_tag_img, |
|
|
148 | html_tag_script, |
|
|
149 | html_tag_form, |
|
|
150 | html_tag_input, |
|
|
151 | html_tag_div, |
|
|
152 | } tag; |
172 | } tag; |
153 | char *command; |
173 | char *command; |
154 | char *name; |
174 | char *name; |
155 | char *href; |
175 | char *href; |
156 | char *refresh_cond; |
176 | char *refresh_cond; |
157 | struct widget *w; |
177 | struct widget *w; |
158 | struct widget *container; |
178 | struct widget *container; |
159 | } html[10]; |
179 | } html[10]; |
160 | }; |
180 | }; |
161 | |
181 | |
162 | |
|
|
163 | |
|
|
164 | |
|
|
165 | static void |
|
|
166 | gui_internal_search_list_set_default_country2(struct gui_priv *this) |
182 | static void gui_internal_search_list_set_default_country2(struct gui_priv *this) |
167 | { |
183 | { |
168 | struct attr search_attr, country_name, country_iso2, *country_attr; |
184 | struct attr search_attr, country_name, country_iso2, *country_attr; |
169 | struct item *item; |
185 | struct item *item; |
170 | struct country_search *cs; |
186 | struct country_search *cs; |
171 | struct tracking *tracking; |
187 | struct tracking *tracking; |
172 | struct search_list_result *res; |
188 | struct search_list_result *res; |
173 | |
189 | |
174 | //dbg(0,"### 1"); |
190 | ////DBG dbg(0,"### 1"); |
175 | |
191 | |
176 | country_attr=country_default(); |
192 | country_attr = country_default(); |
177 | tracking=navit_get_tracking(this->nav); |
193 | tracking = navit_get_tracking(this->nav); |
178 | |
194 | |
179 | if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL)) |
195 | if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL)) |
180 | country_attr=&search_attr; |
196 | country_attr = &search_attr; |
181 | if (country_attr) { |
197 | if (country_attr) |
|
|
198 | { |
182 | //dbg(0,"### 2"); |
199 | ////DBG dbg(0,"### 2"); |
183 | cs=country_search_new(country_attr, 0); |
200 | cs = country_search_new(country_attr, 0); |
184 | item=country_search_get_item(cs); |
201 | item = country_search_get_item(cs); |
185 | if (item && item_attr_get(item, attr_country_name, &country_name)) { |
202 | if (item && item_attr_get(item, attr_country_name, &country_name)) |
|
|
203 | { |
186 | search_attr.type=attr_country_all; |
204 | search_attr.type = attr_country_all; |
187 | //dbg(0,"country %s\n", country_name.u.str); |
205 | ////DBG dbg(0,"country %s\n", country_name.u.str); |
188 | search_attr.u.str=country_name.u.str; |
206 | search_attr.u.str = country_name.u.str; |
189 | search_list_search(this->sl, &search_attr, 0); |
207 | search_list_search(this->sl, &search_attr, 0); |
190 | while((res=search_list_get_result(this->sl))); |
208 | while ((res = search_list_get_result(this->sl))) |
|
|
209 | ; |
191 | if(this->country_iso2) |
210 | if (this->country_iso2) |
192 | { |
211 | { |
193 | // this seems to cause a crash, no idea why |
212 | // this seems to cause a crash, no idea why |
194 | //g_free(this->country_iso2); |
213 | //g_free(this->country_iso2); |
195 | this->country_iso2=NULL; |
214 | this->country_iso2 = NULL; |
196 | } |
215 | } |
197 | if (item_attr_get(item, attr_country_iso2, &country_iso2)) |
216 | if (item_attr_get(item, attr_country_iso2, &country_iso2)) |
198 | { |
217 | { |
199 | this->country_iso2=g_strdup(country_iso2.u.str); |
218 | this->country_iso2 = g_strdup(country_iso2.u.str); |
200 | } |
219 | } |
201 | } |
220 | } |
202 | country_search_destroy(cs); |
221 | country_search_destroy(cs); |
203 | } else { |
222 | } |
|
|
223 | else |
|
|
224 | { |
204 | dbg(0,"warning: no default country found\n"); |
225 | //DBG dbg(0, "warning: no default country found\n"); |
205 | if (this->country_iso2) { |
226 | if (this->country_iso2) |
|
|
227 | { |
206 | dbg(0,"attempting to use country '%s'\n",this->country_iso2); |
228 | //DBG dbg(0, "attempting to use country '%s'\n", this->country_iso2); |
207 | search_attr.type=attr_country_iso2; |
229 | search_attr.type = attr_country_iso2; |
208 | search_attr.u.str=this->country_iso2; |
230 | search_attr.u.str = this->country_iso2; |
209 | search_list_search(this->sl, &search_attr, 0); |
231 | search_list_search(this->sl, &search_attr, 0); |
210 | while((res=search_list_get_result(this->sl))); |
232 | while ((res = search_list_get_result(this->sl))) |
211 | } |
233 | ; |
212 | } |
234 | } |
|
|
235 | } |
213 | //dbg(0,"### 99"); |
236 | ////DBG dbg(0,"### 99"); |
214 | } |
237 | } |
215 | |
|
|
216 | |
|
|
217 | |
238 | |
218 | struct navit *global_navit; |
239 | struct navit *global_navit; |
219 | |
240 | |
220 | |
|
|
221 | int |
|
|
222 | android_find_class_global(char *name, jclass *ret) |
241 | int android_find_class_global(char *name, jclass *ret) |
223 | { |
242 | { |
224 | *ret=(*jnienv)->FindClass(jnienv, name); |
243 | *ret = (*jnienv)->FindClass(jnienv, name); |
225 | if (! *ret) { |
244 | if (!*ret) |
|
|
245 | { |
226 | dbg(0,"Failed to get Class %s\n",name); |
246 | //DBG dbg(0, "Failed to get Class %s\n", name); |
227 | return 0; |
247 | return 0; |
228 | } |
248 | } |
|
|
249 | //DBG dbg(0,"lclass %p\n", *ret); |
229 | (*jnienv)->NewGlobalRef(jnienv, *ret); |
250 | *ret = (*jnienv)->NewGlobalRef(jnienv, *ret); |
|
|
251 | // ICS (*jnienv)->DeleteGlobalRef(jnienv, *lret); |
|
|
252 | //DBG dbg(0,"gclass %p\n", *ret); |
230 | return 1; |
253 | return 1; |
231 | } |
254 | } |
232 | |
255 | |
233 | int |
|
|
234 | android_find_method(jclass class, char *name, char *args, jmethodID *ret) |
256 | int android_find_method(jclass class, char *name, char *args, jmethodID *ret) |
235 | { |
257 | { |
236 | *ret = (*jnienv)->GetMethodID(jnienv, class, name, args); |
258 | *ret = (*jnienv)->GetMethodID(jnienv, class, name, args); |
237 | if (*ret == NULL) { |
259 | if (*ret == NULL) |
|
|
260 | { |
238 | dbg(0,"Failed to get Method %s with signature %s\n",name,args); |
261 | //DBG dbg(0, "Failed to get Method %s with signature %s\n", name, args); |
239 | return 0; |
262 | return 0; |
240 | } |
263 | } |
|
|
264 | //DBG dbg(0,"l meth %p\n", *ret); |
241 | return 1; |
265 | return 1; |
242 | } |
266 | } |
243 | |
267 | |
244 | int |
|
|
245 | android_find_static_method(jclass class, char *name, char *args, jmethodID *ret) |
268 | int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret) |
246 | { |
269 | { |
247 | *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args); |
270 | *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args); |
248 | if (*ret == NULL) { |
271 | if (*ret == NULL) |
|
|
272 | { |
249 | dbg(0,"Failed to get static Method %s with signature %s\n",name,args); |
273 | //DBG dbg(0, "Failed to get static Method %s with signature %s\n", name, args); |
250 | return 0; |
274 | return 0; |
251 | } |
275 | } |
|
|
276 | //DBG dbg(0,"l meth %p\n", *ret); |
252 | return 1; |
277 | return 1; |
253 | } |
278 | } |
254 | |
279 | |
255 | JNIEXPORT void JNICALL |
280 | JNIEXPORT void JNICALL |
256 | Java_com_zoffcc_applications_zanavi_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string) |
281 | Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string) |
257 | { |
282 | { |
|
|
283 | char *strings[] = |
258 | char *strings[]={"/data/data/com.zoffcc.applications.zanavi/bin/navit",NULL}; |
284 | { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL }; |
259 | const char *langstr; |
285 | const char *langstr; |
260 | const char *displaydensitystr; |
286 | const char *displaydensitystr; |
261 | android_version=version; |
287 | android_version = version; |
262 | //__android_log_print(ANDROID_LOG_ERROR,"test","called"); |
288 | //__android_log_print(ANDROID_LOG_ERROR,"test","called"); |
263 | android_activity_cbl=callback_list_new(); |
289 | android_activity_cbl = callback_list_new(); |
|
|
290 | |
|
|
291 | // set global JNIenv here ---------- |
|
|
292 | // set global JNIenv here ---------- |
|
|
293 | // set global JNIenv here ---------- |
264 | jnienv=env; |
294 | jnienv = env; |
|
|
295 | // set global JNIenv here ---------- |
|
|
296 | // set global JNIenv here ---------- |
|
|
297 | // set global JNIenv here ---------- |
|
|
298 | |
|
|
299 | //jclass someClass = env->FindClass("SomeClass"); |
|
|
300 | //gSomeClass = env->NewGlobalRef(someClass); |
|
|
301 | |
|
|
302 | |
265 | android_activity=activity; |
303 | // *only local* android_activity = activity; |
266 | (*jnienv)->NewGlobalRef(jnienv, activity); |
304 | // android_activity = (*jnienv)->NewGlobalRef(jnienv, activity); |
|
|
305 | android_activity = (*env)->NewGlobalRef(env, activity); |
267 | langstr=(*env)->GetStringUTFChars(env, lang, NULL); |
306 | langstr = (*env)->GetStringUTFChars(env, lang, NULL); |
268 | dbg(0,"enter env=%p thiz=%p activity=%p lang=%s version=%d\n",env,thiz,activity,langstr,version); |
307 | //DBG dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version); |
|
|
308 | //DBG dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version); |
269 | setenv("LANG",langstr,1); |
309 | setenv("LANG", langstr, 1); |
270 | (*env)->ReleaseStringUTFChars(env, lang, langstr); |
310 | (*env)->ReleaseStringUTFChars(env, lang, langstr); |
271 | |
311 | |
272 | displaydensitystr=(*env)->GetStringUTFChars(env, display_density_string, NULL); |
312 | displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL); |
273 | dbg(0,"*****displaydensity=%s\n",displaydensitystr); |
313 | //DBG dbg(0, "*****displaydensity=%s\n", displaydensitystr); |
274 | setenv("ANDROID_DENSITY",displaydensitystr,1); |
314 | setenv("ANDROID_DENSITY", displaydensitystr, 1); |
275 | (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr); |
315 | (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr); |
276 | main_real(1, strings); |
316 | main_real(1, strings); |
277 | } |
317 | } |
278 | |
318 | |
279 | JNIEXPORT void JNICALL |
319 | JNIEXPORT void JNICALL |
280 | Java_com_zoffcc_applications_zanavi_Navit_NavitActivity( JNIEnv* env, jobject thiz, int param) |
320 | Java_com_zoffcc_applications_zanavi_Navit_NavitActivity(JNIEnv* env, jobject thiz, int param) |
281 | { |
321 | { |
282 | dbg(0,"enter %d\n",param); |
322 | dbg(0, "enter %d\n", param); |
283 | |
323 | |
284 | if (param == -2) |
324 | if (param == -2) |
285 | { |
325 | { |
286 | // onStop() -> called in Java app |
326 | // onStop() -> called in Java app |
287 | // save center.txt |
327 | // save center.txt |
288 | if (global_navit->bookmarks) |
328 | if (global_navit->bookmarks) |
289 | { |
329 | { |
290 | config_get_attr(config, attr_navit, &attr, NULL); |
330 | config_get_attr(config, attr_navit, &attr, NULL); |
291 | dbg(0,"save position to file"); |
331 | //DBG dbg(0, "save position to file"); |
292 | char *center_file = bookmarks_get_center_file(TRUE); |
332 | char *center_file = bookmarks_get_center_file(TRUE); |
293 | bookmarks_write_center_to_file(attr.u.navit->bookmarks, center_file); |
333 | bookmarks_write_center_to_file(attr.u.navit->bookmarks, center_file); |
|
|
334 | dbg(0,"save pos to file -> ready"); |
294 | g_free(center_file); |
335 | g_free(center_file); |
295 | // bookmarks_destroy(global_navit->bookmarks); |
336 | // bookmarks_destroy(global_navit->bookmarks); |
296 | } |
337 | } |
297 | } |
338 | } |
298 | |
339 | |
|
|
340 | dbg(0,"acti: 001\n"); |
299 | callback_list_call_1(android_activity_cbl, param); |
341 | callback_list_call_1(android_activity_cbl, param); |
|
|
342 | dbg(0,"acti: 002\n"); |
300 | if (param == -3) |
343 | if (param == -4) |
301 | { |
344 | { |
|
|
345 | dbg(0,"acti: 003\n"); |
302 | exit(0); |
346 | exit(0); |
303 | } |
347 | } |
304 | //if (param == -3) |
348 | //if (param == -3) |
305 | //{ |
349 | //{ |
306 | // event_main_loop_quit(); |
350 | // event_main_loop_quit(); |
307 | //} |
351 | //} |
308 | } |
352 | } |
309 | |
353 | |
310 | JNIEXPORT void JNICALL |
354 | JNIEXPORT void JNICALL |
311 | Java_com_zoffcc_applications_zanavi_NavitGraphics_SizeChangedCallback( JNIEnv* env, jobject thiz, int id, int w, int h) |
355 | Java_com_zoffcc_applications_zanavi_NavitGraphics_SizeChangedCallback(JNIEnv* env, jobject thiz, int id, int w, int h) |
312 | { |
356 | { |
|
|
357 | //DBG dbg(0,"enter %p %d %d\n", id, w, h); |
|
|
358 | navit_handle_resize(global_navit, w, h); |
|
|
359 | |
|
|
360 | // //DBG dbg(0,"== part2 ==\n"); |
|
|
361 | |
|
|
362 | //if (id) |
|
|
363 | //{ |
|
|
364 | // callback_call_2((struct callback *) id, w, h); |
|
|
365 | //} |
|
|
366 | |
|
|
367 | //DBG dbg(0,"leave\n"); |
|
|
368 | } |
|
|
369 | |
|
|
370 | JNIEXPORT void JNICALL |
|
|
371 | Java_com_zoffcc_applications_zanavi_NavitGraphics_ButtonCallback(JNIEnv* env, jobject thiz, int id, int pressed, int button, int x, int y) |
|
|
372 | { |
313 | //dbg(0,"enter %p %d %d\n",(struct callback *)id,w,h); |
373 | //DBG dbg(0, "enter %p %d %d\n", (struct callback *) id, pressed, button); |
314 | if (id) |
374 | if (id) |
315 | { |
|
|
316 | callback_call_2((struct callback *)id,w,h); |
375 | callback_call_4((struct callback *) id, pressed, button, x, y); |
317 | } |
|
|
318 | } |
376 | } |
319 | |
377 | |
320 | JNIEXPORT void JNICALL |
378 | JNIEXPORT void JNICALL |
321 | Java_com_zoffcc_applications_zanavi_NavitGraphics_ButtonCallback( JNIEnv* env, jobject thiz, int id, int pressed, int button, int x, int y) |
379 | Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallback(JNIEnv* env, jobject thiz, int id, int x, int y) |
322 | { |
380 | { |
323 | dbg(1,"enter %p %d %d\n",(struct callback *)id,pressed,button); |
381 | //DBG dbg(0, "enter %p %d %d\n", (struct callback *) id, x, y); |
324 | if (id) |
382 | if (id) |
325 | callback_call_4((struct callback *)id,pressed,button,x,y); |
383 | callback_call_2((struct callback *) id, x, y); |
326 | } |
384 | } |
327 | |
385 | |
328 | JNIEXPORT void JNICALL |
386 | JNIEXPORT void JNICALL |
329 | Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallback( JNIEnv* env, jobject thiz, int id, int x, int y) |
387 | Java_com_zoffcc_applications_zanavi_NavitGraphics_KeypressCallback(JNIEnv* env, jobject thiz, int id, jobject str) |
330 | { |
388 | { |
|
|
389 | //DBG dbg(0,"EEnter\n"); |
|
|
390 | const char *s; |
331 | dbg(1,"enter %p %d %d\n",(struct callback *)id,x,y); |
391 | ////DBG dbg(0,"enter %p %p\n",(struct callback *)id,str); |
|
|
392 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
393 | ////DBG dbg(0,"key=%s\n",s); |
332 | if (id) |
394 | if (id) |
|
|
395 | { |
333 | callback_call_2((struct callback *)id,x,y); |
396 | callback_call_1((struct callback *) id, s); |
|
|
397 | } |
|
|
398 | (*env)->ReleaseStringUTFChars(env, str, s); |
334 | } |
399 | } |
335 | |
400 | |
336 | JNIEXPORT void JNICALL |
401 | JNIEXPORT void JNICALL |
337 | Java_com_zoffcc_applications_zanavi_NavitGraphics_KeypressCallback( JNIEnv* env, jobject thiz, int id, jobject str) |
402 | Java_com_zoffcc_applications_zanavi_NavitTimeout_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id) |
338 | { |
403 | { |
339 | const char *s; |
404 | //DBG dbg(0,"enter %p %d %p\n",thiz, delete, (void *)id); |
340 | //dbg(0,"enter %p %p\n",(struct callback *)id,str); |
405 | //DBG dbg(0,"timeout 1\n"); |
341 | s=(*env)->GetStringUTFChars(env, str, NULL); |
406 | // ICS |
342 | //dbg(0,"key=%s\n",s); |
|
|
343 | if (id) |
|
|
344 | callback_call_1((struct callback *)id,s); |
407 | callback_call_0((struct callback *) id); |
345 | (*env)->ReleaseStringUTFChars(env, str, s); |
408 | // ICS |
|
|
409 | //DBG dbg(0,"timeout 2\n"); |
|
|
410 | if (delete) |
|
|
411 | { |
|
|
412 | //DBG dbg(0,"timeout 3\n"); |
|
|
413 | // ICS |
|
|
414 | // (*jnienv)->DeleteGlobalRef(jnienv, thiz); |
|
|
415 | // ICS |
|
|
416 | //DBG dbg(0,"timeout 4\n"); |
|
|
417 | } |
346 | } |
418 | } |
347 | |
419 | |
348 | JNIEXPORT void JNICALL |
420 | JNIEXPORT void JNICALL |
349 | Java_com_zoffcc_applications_zanavi_NavitTimeout_TimeoutCallback( JNIEnv* env, jobject thiz, int delete, int id) |
421 | Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv * env, jobject thiz, int id, jobject location) |
350 | { |
422 | { |
351 | // dbg(1,"enter %p %d %p\n",thiz, delete, (void *)id); |
423 | //DBG dbg(0,"enter %p %p\n",thiz, (void *)id); |
|
|
424 | |
|
|
425 | // ***** calls: vehicle_android.c -> vehicle_android_callback() |
352 | callback_call_0((struct callback *)id); |
426 | callback_call_1((struct callback *) id, (void *) location); |
353 | if (delete) |
|
|
354 | { |
|
|
355 | (*jnienv)->DeleteGlobalRef(jnienv, thiz); |
|
|
356 | } |
|
|
357 | } |
427 | } |
358 | |
428 | |
359 | JNIEXPORT void JNICALL |
429 | JNIEXPORT void JNICALL |
360 | Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback( JNIEnv * env, jobject thiz, int id, jobject location) |
430 | Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id) |
361 | { |
431 | { |
362 | // dbg(0,"enter %p %p\n",thiz, (void *)id); |
432 | //DBG dbg(0,"enter %p %p\n",thiz, (void *)id); |
363 | |
|
|
364 | // ***** calls: vehicle_android.c -> vehicle_android_callback() |
|
|
365 | callback_call_1((struct callback *)id, (void *)location); |
433 | callback_call_0((struct callback *) id); |
366 | } |
434 | } |
367 | |
435 | |
368 | JNIEXPORT void JNICALL |
436 | JNIEXPORT void JNICALL |
369 | Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback( JNIEnv* env, jobject thiz, int id) |
437 | Java_com_zoffcc_applications_zanavi_NavitWatch_poll(JNIEnv* env, jobject thiz, int fd, int cond) |
370 | { |
438 | { |
371 | // dbg(0,"enter %p %p\n",thiz, (void *)id); |
439 | struct pollfd pfd; |
372 | callback_call_0((struct callback *)id); |
440 | pfd.fd = fd; |
|
|
441 | //DBG dbg(0, "%p poll called for %d %d\n", env, fd, cond); |
|
|
442 | switch ((enum event_watch_cond) cond) |
|
|
443 | { |
|
|
444 | case event_watch_cond_read: |
|
|
445 | pfd.events = POLLIN; |
|
|
446 | break; |
|
|
447 | case event_watch_cond_write: |
|
|
448 | pfd.events = POLLOUT; |
|
|
449 | break; |
|
|
450 | case event_watch_cond_except: |
|
|
451 | pfd.events = POLLERR; |
|
|
452 | break; |
|
|
453 | default: |
|
|
454 | pfd.events = 0; |
|
|
455 | } |
|
|
456 | pfd.revents = 0; |
|
|
457 | poll(&pfd, 1, -1); |
373 | } |
458 | } |
374 | |
459 | |
375 | JNIEXPORT void JNICALL |
460 | JNIEXPORT void JNICALL |
376 | Java_com_zoffcc_applications_zanavi_NavitWatch_poll( JNIEnv* env, jobject thiz, int fd, int cond) |
461 | Java_com_zoffcc_applications_zanavi_NavitWatch_WatchCallback(JNIEnv* env, jobject thiz, int id) |
377 | { |
462 | { |
378 | struct pollfd pfd; |
463 | //DBG dbg(0, "enter %p %p\n", thiz, (void *) id); |
379 | pfd.fd=fd; |
464 | callback_call_0((struct callback *) id); |
380 | dbg(1,"%p poll called for %d %d\n",env, fd, cond); |
|
|
381 | switch ((enum event_watch_cond)cond) { |
|
|
382 | case event_watch_cond_read: |
|
|
383 | pfd.events=POLLIN; |
|
|
384 | break; |
|
|
385 | case event_watch_cond_write: |
|
|
386 | pfd.events=POLLOUT; |
|
|
387 | break; |
|
|
388 | case event_watch_cond_except: |
|
|
389 | pfd.events=POLLERR; |
|
|
390 | break; |
|
|
391 | default: |
|
|
392 | pfd.events=0; |
|
|
393 | } |
|
|
394 | pfd.revents=0; |
|
|
395 | poll(&pfd, 1, -1); |
|
|
396 | } |
465 | } |
397 | |
466 | |
398 | JNIEXPORT void JNICALL |
467 | JNIEXPORT void JNICALL |
399 | Java_com_zoffcc_applications_zanavi_NavitWatch_WatchCallback( JNIEnv* env, jobject thiz, int id) |
|
|
400 | { |
|
|
401 | dbg(1,"enter %p %p\n",thiz, (void *)id); |
|
|
402 | callback_call_0((struct callback *)id); |
|
|
403 | } |
|
|
404 | |
|
|
405 | |
|
|
406 | JNIEXPORT void JNICALL |
|
|
407 | Java_com_zoffcc_applications_zanavi_NavitSensors_SensorCallback( JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z) |
468 | Java_com_zoffcc_applications_zanavi_NavitSensors_SensorCallback(JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z) |
408 | { |
469 | { |
409 | dbg(1,"enter %p %p %f %f %f\n",thiz, (void *)id,x,y,z); |
470 | //DBG dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z); |
410 | callback_call_4((struct callback *)id, sensor, &x, &y, &z); |
471 | callback_call_4((struct callback *) id, sensor, &x, &y, &z); |
411 | } |
472 | } |
412 | |
473 | |
413 | void |
|
|
414 | android_return_search_result(struct jni_object *jni_o, char *str) |
474 | void android_return_search_result(struct jni_object *jni_o, char *str) |
415 | { |
475 | { |
|
|
476 | //DBG dbg(0,"EEnter\n"); |
416 | jstring js2 = NULL; |
477 | jstring js2 = NULL; |
417 | JNIEnv* env2; |
478 | JNIEnv* env2; |
418 | env2=jni_o->env; |
479 | env2 = jni_o->env; |
419 | js2 = (*env2)->NewStringUTF(jni_o->env,str); |
480 | js2 = (*env2)->NewStringUTF(jni_o->env, str); |
420 | (*env2)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, js2); |
481 | (*env2)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, js2); |
421 | (*env2)->DeleteLocalRef(jni_o->env, js2); |
482 | (*env2)->DeleteLocalRef(jni_o->env, js2); |
422 | } |
483 | } |
423 | |
484 | |
424 | void |
|
|
425 | android_return_generic_int(int id, int i) |
485 | void android_return_generic_int(int id, int i) |
426 | { |
486 | { |
|
|
487 | //DBG dbg(0,"Enter\n"); |
427 | if (NavitGraphicsClass2 == NULL) |
488 | if (NavitGraphicsClass2 == NULL) |
428 | { |
489 | { |
429 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2)) |
490 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2)) |
430 | { |
491 | { |
431 | NavitGraphicsClass2=NULL; |
492 | NavitGraphicsClass2 = NULL; |
432 | return; |
493 | return; |
433 | } |
494 | } |
434 | } |
495 | } |
|
|
496 | //DBG dbg(0,"xx1\n"); |
435 | if (return_generic_int == NULL) |
497 | if (return_generic_int == NULL) |
436 | { |
498 | { |
437 | android_find_static_method(NavitGraphicsClass2,"return_generic_int", "(II)V", &return_generic_int); |
499 | android_find_static_method(NavitGraphicsClass2, "return_generic_int", "(II)V", &return_generic_int); |
438 | } |
500 | } |
|
|
501 | //DBG dbg(0,"xx2\n"); |
439 | if (return_generic_int == NULL) |
502 | if (return_generic_int == NULL) |
440 | { |
503 | { |
441 | dbg(0,"no method found\n"); |
504 | //DBG dbg(0, "no method found\n"); |
442 | return; /* exception thrown */ |
505 | return; /* exception thrown */ |
443 | } |
506 | } |
|
|
507 | //DBG dbg(0,"xa1\n"); |
444 | // -crash- (*jnienv)->CallVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
508 | // -crash- (*jnienv)->CallVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
445 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
509 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
446 | // -works- (*jnienv)->CallStaticObjectMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
510 | // -works- (*jnienv)->CallStaticObjectMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); |
|
|
511 | //DBG dbg(0,"xa2\n"); |
447 | } |
512 | } |
448 | |
|
|
449 | |
513 | |
450 | JNIEXPORT void JNICALL |
514 | JNIEXPORT void JNICALL |
451 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList( JNIEnv* env, jobject thiz, int id, int partial, jobject str,int search_flags,jobject search_country, jobject latlon, int radius) |
515 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, int search_flags, jobject search_country, jobject latlon, int radius) |
452 | { |
516 | { |
453 | const char *s; |
517 | const char *s; |
454 | s=(*env)->GetStringUTFChars(env, str, NULL); |
518 | s = (*env)->GetStringUTFChars(env, str, NULL); |
455 | //dbg(0,"*****string=%s\n",s); |
519 | ////DBG dbg(0,"*****string=%s\n",s); |
456 | |
520 | |
457 | |
521 | |
458 | config_get_attr(config, attr_navit, &attr, NULL); |
522 | config_get_attr(config, attr_navit, &attr, NULL); |
459 | // attr.u.navit |
523 | // attr.u.navit |
460 | |
524 | |
461 | jstring js2 = NULL; |
525 | jstring js2 = NULL; |
462 | jclass cls = (*env)->GetObjectClass(env,thiz); |
526 | jclass cls_local = (*env)->GetObjectClass(env, thiz); |
|
|
527 | |
|
|
528 | // ICS ??? |
|
|
529 | jclass cls = (*env)->NewGlobalRef(env, cls_local); |
|
|
530 | // ICS ??? |
|
|
531 | |
463 | jmethodID aMethodID = (*env)->GetMethodID(env, cls, "fillStringArray", "(Ljava/lang/String;)V"); |
532 | jmethodID aMethodID = (*env)->GetMethodID(env, cls, "fillStringArray", "(Ljava/lang/String;)V"); |
464 | if(aMethodID == 0) |
533 | if (aMethodID == 0) |
465 | { |
534 | { |
466 | //dbg(0,"**** Unable to get methodID: fillStringArray"); |
535 | ////DBG dbg(0,"**** Unable to get methodID: fillStringArray"); |
467 | return; |
536 | return; |
468 | } |
537 | } |
469 | |
538 | |
470 | if (id) |
539 | if (id) |
471 | { |
540 | { |
472 | // search for town in variable "s" within current country -> return a list of towns as result |
541 | // search for town in variable "s" within current country -> return a list of towns as result |
473 | if (id==1) |
542 | if (id == 1) |
474 | { |
543 | { |
475 | // unused now!! |
544 | // unused now!! |
476 | } |
545 | } |
477 | // search for street in variable "s" within "search_country" -> return a list of streets as result |
546 | // search for street in variable "s" within "search_country" -> return a list of streets as result |
478 | else if (id == 2) |
547 | else if (id == 2) |
… | |
… | |
482 | //struct gui_priv gp_24; |
551 | //struct gui_priv gp_24; |
483 | |
552 | |
484 | offline_search_break_searching = 0; |
553 | offline_search_break_searching = 0; |
485 | |
554 | |
486 | struct jni_object my_jni_object; |
555 | struct jni_object my_jni_object; |
487 | my_jni_object.env=env; |
556 | my_jni_object.env = env; |
488 | my_jni_object.jo=thiz; |
557 | my_jni_object.jo = thiz; |
489 | my_jni_object.jm=aMethodID; |
558 | my_jni_object.jm = aMethodID; |
490 | |
559 | |
491 | //gp4=&gp_24; |
560 | //gp4=&gp_24; |
492 | //gp4->nav=attr.u.navit; |
561 | //gp4->nav=attr.u.navit; |
493 | struct mapset *ms4=navit_get_mapset(attr.u.navit); |
562 | struct mapset *ms4 = navit_get_mapset(attr.u.navit); |
494 | GList *ret=NULL; |
563 | GList *ret = NULL; |
495 | int flags=search_flags; |
564 | int flags = search_flags; |
496 | char *search_country_string=(*env)->GetStringUTFChars(env, search_country, NULL); |
565 | char *search_country_string = (*env)->GetStringUTFChars(env, search_country, NULL); |
497 | ret=search_by_address(ret,ms4,s,partial,&my_jni_object,flags,search_country_string); |
566 | ret = search_by_address(ret, ms4, s, partial, &my_jni_object, flags, search_country_string); |
498 | (*env)->ReleaseStringUTFChars(env, search_country, search_country_string); |
567 | (*env)->ReleaseStringUTFChars(env, search_country, search_country_string); |
499 | |
568 | |
500 | // free the memory |
569 | // free the memory |
501 | g_list_free(ret); |
570 | g_list_free(ret); |
502 | //dbg(0,"ret=%p\n",ret); |
571 | ////DBG dbg(0,"ret=%p\n",ret); |
503 | |
572 | |
504 | |
573 | |
505 | //if (gp4->sl) |
574 | //if (gp4->sl) |
506 | //{ |
575 | //{ |
507 | // //search_list_destroy(gp4->sl); |
576 | // //search_list_destroy(gp4->sl); |
… | |
… | |
510 | } |
579 | } |
511 | // do a full search in all mapfiles for string in variable "s" -> return a list of streets as result |
580 | // do a full search in all mapfiles for string in variable "s" -> return a list of streets as result |
512 | else if (id == 3) |
581 | else if (id == 3) |
513 | { |
582 | { |
514 | const char *s3; |
583 | const char *s3; |
515 | s3=(*env)->GetStringUTFChars(env, latlon, NULL); |
584 | s3 = (*env)->GetStringUTFChars(env, latlon, NULL); |
516 | char parse_str[strlen(s3) + 1]; |
585 | char parse_str[strlen(s3) + 1]; |
517 | strcpy(parse_str, s3); |
586 | strcpy(parse_str, s3); |
518 | (*env)->ReleaseStringUTFChars(env, latlon, s3); |
587 | (*env)->ReleaseStringUTFChars(env, latlon, s3); |
519 | |
588 | |
520 | struct coord_geo g7; |
589 | struct coord_geo g7; |
521 | char *p; |
590 | char *p; |
522 | char *stopstring; |
591 | char *stopstring; |
523 | |
592 | |
524 | // lat |
593 | // lat |
525 | p = strtok (parse_str,"#"); |
594 | p = strtok(parse_str, "#"); |
526 | g7.lat = strtof(p, &stopstring); |
595 | g7.lat = strtof(p, &stopstring); |
527 | // lon |
596 | // lon |
528 | p = strtok (NULL, "#"); |
597 | p = strtok(NULL, "#"); |
529 | g7.lng = strtof(p, &stopstring); |
598 | g7.lng = strtof(p, &stopstring); |
530 | |
599 | |
531 | struct jni_object my_jni_object; |
600 | struct jni_object my_jni_object; |
532 | my_jni_object.env=env; |
601 | my_jni_object.env = env; |
533 | my_jni_object.jo=thiz; |
602 | my_jni_object.jo = thiz; |
534 | my_jni_object.jm=aMethodID; |
603 | my_jni_object.jm = aMethodID; |
535 | // search_flags --> is search_order (search at what "order" level) |
604 | // search_flags --> is search_order (search at what "order" level) |
536 | search_full_world(s, partial, search_flags, &my_jni_object, &g7, radius); |
605 | search_full_world(s, partial, search_flags, &my_jni_object, &g7, radius); |
537 | } |
606 | } |
538 | } |
607 | } |
539 | |
608 | |
540 | (*env)->ReleaseStringUTFChars(env, str, s); |
609 | (*env)->ReleaseStringUTFChars(env, str, s); |
541 | } |
610 | } |
542 | |
611 | |
543 | JNIEXPORT jint JNICALL |
612 | JNIEXPORT jint JNICALL |
544 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackDestinationValid( JNIEnv* env, jobject thiz) |
613 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackDestinationValid(JNIEnv* env, jobject thiz) |
545 | { |
614 | { |
|
|
615 | //DBG dbg(0,"EEnter\n"); |
546 | config_get_attr(config, attr_navit, &attr, NULL); |
616 | config_get_attr(config, attr_navit, &attr, NULL); |
547 | // dbg(0,"destination_valid=%d\n",attr.u.navit->destination_valid); |
617 | // //DBG dbg(0,"destination_valid=%d\n",attr.u.navit->destination_valid); |
548 | jint i=0; |
618 | jint i = 0; |
549 | if (attr.u.navit->route) |
619 | if (attr.u.navit->route) |
550 | { |
620 | { |
551 | struct route *r; |
621 | struct route *r; |
552 | r=attr.u.navit->route; |
622 | r = attr.u.navit->route; |
553 | i=r->route_status; |
623 | i = r->route_status; |
554 | // dbg(0,"route_status=%d\n",i); |
624 | // //DBG dbg(0,"route_status=%d\n",i); |
555 | } |
625 | } |
556 | return i; |
626 | return i; |
557 | } |
627 | } |
558 | |
628 | |
559 | static void map_preview_label_line(struct point *p, int count, char *label, int font_size) |
629 | static void map_preview_label_line(struct point *p, int count, char *label, int font_size) |
560 | { |
630 | { |
561 | int i,x,y,tl,tlm,th,thm,tlsq,l; |
631 | int i, x, y, tl, tlm, th, thm, tlsq, l; |
562 | float lsq; |
632 | float lsq; |
563 | double dx,dy; |
633 | double dx, dy; |
564 | struct point p_t; |
634 | struct point p_t; |
565 | struct point pb[5]; |
635 | struct point pb[5]; |
566 | |
636 | |
567 | int len = g_utf8_strlen(label, -1); |
637 | int len = g_utf8_strlen(label, -1); |
568 | int xMin = 0; |
638 | int xMin = 0; |
569 | int yMin = 0; |
639 | int yMin = 0; |
570 | int yMax = 13*font_size/256; |
640 | int yMax = 13 * font_size / 256; |
571 | int xMax = 9*font_size*len/256; |
641 | int xMax = 9 * font_size * len / 256; |
572 | |
642 | |
573 | //dbg(0,"xMax=%d\n", xMax); |
643 | ////DBG dbg(0,"xMax=%d\n", xMax); |
574 | //dbg(0,"yMax=%d\n", yMax); |
644 | ////DBG dbg(0,"yMax=%d\n", yMax); |
575 | |
645 | |
576 | pb[0].x = xMin; |
646 | pb[0].x = xMin; |
577 | pb[0].y = -yMin; |
647 | pb[0].y = -yMin; |
578 | pb[1].x = xMin; |
648 | pb[1].x = xMin; |
579 | pb[1].y = -yMax; |
649 | pb[1].y = -yMax; |
580 | pb[2].x = xMax; |
650 | pb[2].x = xMax; |
581 | pb[2].y = -yMax; |
651 | pb[2].y = -yMax; |
582 | pb[3].x = xMax; |
652 | pb[3].x = xMax; |
583 | pb[3].y = -yMin; |
653 | pb[3].y = -yMin; |
584 | |
654 | |
585 | tl=(pb[2].x-pb[0].x); |
655 | tl = (pb[2].x - pb[0].x); |
586 | th=(pb[0].y-pb[1].y); |
656 | th = (pb[0].y - pb[1].y); |
587 | |
657 | |
588 | // calc "tl" text length |
658 | // calc "tl" text length |
589 | // tl=strlen(label)*4; |
659 | // tl=strlen(label)*4; |
590 | // calc "th" text height |
660 | // calc "th" text height |
591 | // th=8; |
661 | // th=8; |
592 | |
662 | |
593 | tlm=tl*32; |
663 | tlm = tl * 32; |
594 | thm=th*36; |
664 | thm = th * 36; |
595 | tlsq = (tlm*0.7)*(tlm*0.7); |
665 | tlsq = (tlm * 0.7) * (tlm * 0.7); |
596 | |
666 | |
597 | for (i = 0 ; i < count-1 ; i++) |
667 | for (i = 0; i < count - 1; i++) |
598 | { |
668 | { |
599 | dx=p[i+1].x-p[i].x; |
669 | dx = p[i + 1].x - p[i].x; |
600 | dx*=32; |
670 | dx *= 32; |
601 | dy=p[i+1].y-p[i].y; |
671 | dy = p[i + 1].y - p[i].y; |
602 | dy*=32; |
672 | dy *= 32; |
603 | lsq = dx*dx+dy*dy; |
673 | lsq = dx * dx + dy * dy; |
604 | |
674 | |
605 | if (lsq > tlsq) |
675 | if (lsq > tlsq) |
606 | { |
676 | { |
607 | //dbg(0,"-------- label=%s\n",label); |
677 | ////DBG dbg(0,"-------- label=%s\n",label); |
608 | //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); |
678 | ////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); |
609 | //dbg(0,"dx=%f dy=%f\n",dx,dy); |
679 | ////DBG dbg(0,"dx=%f dy=%f\n",dx,dy); |
610 | l=(int)sqrtf(lsq); |
680 | l = (int) sqrtf(lsq); |
611 | //dbg(0,"l=%d lsq=%f\n",l,lsq); |
681 | ////DBG dbg(0,"l=%d lsq=%f\n",l,lsq); |
612 | x=p[i].x; |
682 | x = p[i].x; |
613 | y=p[i].y; |
683 | y = p[i].y; |
614 | if (dx < 0) |
684 | if (dx < 0) |
615 | { |
685 | { |
616 | dx=-dx; |
686 | dx = -dx; |
617 | dy=-dy; |
687 | dy = -dy; |
618 | x=p[i+1].x; |
688 | x = p[i + 1].x; |
619 | y=p[i+1].y; |
689 | y = p[i + 1].y; |
620 | } |
690 | } |
621 | x+=(l-tlm)*dx/l/64; |
691 | x += (l - tlm) * dx / l / 64; |
622 | y+=(l-tlm)*dy/l/64; |
692 | y += (l - tlm) * dy / l / 64; |
623 | x-=dy*thm/l/64; |
693 | x -= dy * thm / l / 64; |
624 | y+=dx*thm/l/64; |
694 | y += dx * thm / l / 64; |
625 | p_t.x=x; |
695 | p_t.x = x; |
626 | p_t.y=y; |
696 | p_t.y = y; |
627 | |
697 | |
628 | //dbg(0,"dx=%f dy=%f\n",dx,dy); |
698 | ////DBG dbg(0,"dx=%f dy=%f\n",dx,dy); |
629 | //dbg(0,"dx=%d dy=%d\n",(int)dx,(int)dy); |
699 | ////DBG dbg(0,"dx=%d dy=%d\n",(int)dx,(int)dy); |
630 | //dbg(0,"draw px=%d py=%d\n",p_t.x,p_t.y); |
700 | ////DBG dbg(0,"draw px=%d py=%d\n",p_t.x,p_t.y); |
631 | //dbg(0,"l=%d\n",l); |
701 | ////DBG dbg(0,"l=%d\n",l); |
632 | //dbg(0,"+++++++++++++\n"); |
702 | ////DBG dbg(0,"+++++++++++++\n"); |
633 | // **OLD and wrong** android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, dx*0x10000/l, dy*0x10000/l); |
703 | // **OLD and wrong** android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, dx*0x10000/l, dy*0x10000/l); |
634 | android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, (int)dx, (int)dy); |
704 | android_DrawMapPreview_text(p_t.x, p_t.y, label, font_size, (int) dx, (int) dy); |
635 | } |
|
|
636 | } |
705 | } |
|
|
706 | } |
637 | } |
707 | } |
638 | |
|
|
639 | |
708 | |
640 | JNIEXPORT void JNICALL |
709 | JNIEXPORT void JNICALL |
641 | 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) |
710 | 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) |
642 | { |
711 | { |
643 | // config_get_attr(config, attr_navit, &attr, NULL); |
712 | // config_get_attr(config, attr_navit, &attr, NULL); |
644 | |
713 | |
645 | const char *s; |
714 | const char *s; |
646 | int zoom; |
715 | int zoom; |
647 | s=(*env)->GetStringUTFChars(env, latlonzoom, NULL); |
716 | s = (*env)->GetStringUTFChars(env, latlonzoom, NULL); |
648 | char parse_str[strlen(s) + 1]; |
717 | char parse_str[strlen(s) + 1]; |
649 | strcpy(parse_str, s); |
718 | strcpy(parse_str, s); |
650 | (*env)->ReleaseStringUTFChars(env, latlonzoom, s); |
719 | (*env)->ReleaseStringUTFChars(env, latlonzoom, s); |
651 | //dbg(0,"*****string=%s\n",s); |
720 | ////DBG dbg(0,"*****string=%s\n",s); |
652 | |
721 | |
653 | // show map preview for (lat#lon#zoom) |
722 | // show map preview for (lat#lon#zoom) |
654 | struct coord_geo g; |
723 | struct coord_geo g; |
655 | char *p; |
724 | char *p; |
656 | char *stopstring; |
725 | char *stopstring; |
657 | |
726 | |
658 | // lat |
727 | // lat |
659 | p = strtok (parse_str,"#"); |
728 | p = strtok(parse_str, "#"); |
660 | g.lat = strtof(p, &stopstring); |
729 | g.lat = strtof(p, &stopstring); |
661 | // lon |
730 | // lon |
662 | p = strtok (NULL, "#"); |
731 | p = strtok(NULL, "#"); |
663 | g.lng = strtof(p, &stopstring); |
732 | g.lng = strtof(p, &stopstring); |
664 | // zoom |
733 | // zoom |
665 | p = strtok (NULL, "#"); |
734 | p = strtok(NULL, "#"); |
666 | zoom=atoi(p); |
735 | zoom = atoi(p); |
667 | |
736 | |
668 | //dbg(0,"lat=%f\n",g.lat); |
737 | ////DBG dbg(0,"lat=%f\n",g.lat); |
669 | //dbg(0,"lng=%f\n",g.lng); |
738 | ////DBG dbg(0,"lng=%f\n",g.lng); |
670 | //dbg(0,"zoom=%d\n",zoom); |
739 | ////DBG dbg(0,"zoom=%d\n",zoom); |
671 | //dbg(0,"w=%d\n",width); |
740 | ////DBG dbg(0,"w=%d\n",width); |
672 | //dbg(0,"h=%d\n",height); |
741 | ////DBG dbg(0,"h=%d\n",height); |
673 | |
742 | |
674 | struct coord c; |
743 | struct coord c; |
675 | transform_from_geo(projection_mg, &g, &c); |
744 | transform_from_geo(projection_mg, &g, &c); |
676 | |
745 | |
677 | // struct pcoord pc; |
746 | // struct pcoord pc; |
… | |
… | |
683 | // ----------------------- big draw loop ----------------------- |
752 | // ----------------------- big draw loop ----------------------- |
684 | // ----------------------- big draw loop ----------------------- |
753 | // ----------------------- big draw loop ----------------------- |
685 | // ----------------------- big draw loop ----------------------- |
754 | // ----------------------- big draw loop ----------------------- |
686 | // ----------------------- big draw loop ----------------------- |
755 | // ----------------------- big draw loop ----------------------- |
687 | struct item *item; |
756 | struct item *item; |
688 | struct map_rect *mr=NULL; |
757 | struct map_rect *mr = NULL; |
689 | struct mapset *ms; |
758 | struct mapset *ms; |
690 | struct mapset_handle *msh; |
759 | struct mapset_handle *msh; |
691 | struct map* map = NULL; |
760 | struct map* map = NULL; |
692 | struct attr map_name_attr; |
761 | struct attr map_name_attr; |
693 | struct attr attr; |
762 | struct attr attr; |
694 | |
763 | |
695 | struct map_selection sel; |
764 | struct map_selection sel; |
696 | const int selection_range = sel_range; // should be something with "width" and "height" i guess ??!! |
765 | const int selection_range = sel_range; // should be something with "width" and "height" i guess ??!! |
697 | |
766 | |
698 | const int max=100; |
767 | const int max = 100; |
699 | int count; |
768 | int count; |
700 | struct coord *ca=g_alloca(sizeof(struct coord)*max); |
769 | struct coord *ca = g_alloca(sizeof(struct coord) * max); |
701 | struct point *pa=g_alloca(sizeof(struct point)*max); |
770 | struct point *pa = g_alloca(sizeof(struct point) * max); |
702 | |
771 | |
703 | sel.next=NULL; |
772 | sel.next = NULL; |
704 | sel.order=zoom; |
773 | sel.order = zoom; |
705 | sel.range.min=type_none; |
774 | sel.range.min = type_none; |
706 | sel.range.max=type_last; |
775 | sel.range.max = type_last; |
707 | sel.u.c_rect.lu.x=c.x-selection_range; |
776 | sel.u.c_rect.lu.x = c.x - selection_range; |
708 | sel.u.c_rect.lu.y=c.y+selection_range; |
777 | sel.u.c_rect.lu.y = c.y + selection_range; |
709 | sel.u.c_rect.rl.x=c.x+selection_range; |
778 | sel.u.c_rect.rl.x = c.x + selection_range; |
710 | sel.u.c_rect.rl.y=c.y-selection_range; |
779 | sel.u.c_rect.rl.y = c.y - selection_range; |
711 | |
780 | |
712 | struct transformation *tr; |
781 | struct transformation *tr; |
713 | tr=transform_dup(global_navit->trans); |
782 | tr = transform_dup(global_navit->trans); |
714 | struct point p_center; |
783 | struct point p_center; |
715 | p_center.x=width/2; |
784 | p_center.x = width / 2; |
716 | p_center.y=height/2; |
785 | p_center.y = height / 2; |
717 | transform_set_screen_center(tr, &p_center); |
786 | transform_set_screen_center(tr, &p_center); |
718 | transform_set_center(tr, &c); |
787 | transform_set_center(tr, &c); |
719 | transform_set_scale(tr, scale); |
788 | transform_set_scale(tr, scale); |
720 | enum projection pro=transform_get_projection(global_navit->trans_cursor); |
789 | enum projection pro = transform_get_projection(global_navit->trans_cursor); |
721 | |
790 | |
722 | ms=global_navit->mapsets->data; |
791 | ms = global_navit->mapsets->data; |
723 | msh=mapset_open(ms); |
792 | msh = mapset_open(ms); |
724 | while (msh && (map=mapset_next(msh, 0))) |
793 | while (msh && (map = mapset_next(msh, 0))) |
725 | { |
794 | { |
726 | if(map_get_attr(map,attr_name, &map_name_attr,NULL)) |
795 | if (map_get_attr(map, attr_name, &map_name_attr, NULL)) |
727 | { |
796 | { |
728 | if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
797 | if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
729 | { |
798 | { |
730 | if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) |
799 | if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) |
731 | { |
800 | { |
732 | // country borders |
801 | // country borders |
733 | // dbg(0,"map name=%s",map_name_attr.u.str); |
802 | // //DBG dbg(0,"map name=%s",map_name_attr.u.str); |
734 | mr=map_rect_new(map, NULL); |
803 | mr = map_rect_new(map, NULL); |
735 | if (mr) |
804 | if (mr) |
736 | { |
805 | { |
737 | while ((item=map_rect_get_item(mr))) |
806 | while ((item = map_rect_get_item(mr))) |
738 | { |
807 | { |
739 | |
808 | |
740 | // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel); |
809 | // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel); |
741 | count=item_coord_get_within_selection(item, ca, max, &sel); |
810 | count = item_coord_get_within_selection(item, ca, max, &sel); |
742 | if (! count) |
811 | if (!count) |
743 | { |
812 | { |
744 | continue; |
813 | continue; |
745 | } |
814 | } |
746 | count=transform(tr, pro, ca, pa, count, 0, 0, NULL); |
815 | count = transform(tr, pro, ca, pa, count, 0, 0, NULL); |
747 | |
816 | |
748 | // dbg(0,"uu %s\n",item_to_name(item->type)); |
817 | // //DBG dbg(0,"uu %s\n",item_to_name(item->type)); |
749 | |
818 | |
750 | if (item->type == type_border_country) |
819 | if (item->type == type_border_country) |
751 | { |
820 | { |
752 | // dbg(0,"BB** %s\n",item_to_name(item->type)); |
821 | // //DBG dbg(0,"BB** %s\n",item_to_name(item->type)); |
753 | android_DrawMapPreview_polyline(pa, count, 2); |
822 | android_DrawMapPreview_polyline(pa, count, 2); |
754 | } |
823 | } |
755 | } |
824 | } |
756 | map_rect_destroy(mr); |
825 | map_rect_destroy(mr); |
757 | } |
826 | } |
758 | } |
827 | } |
759 | else if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0) |
828 | else if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/navitmap", map_name_attr.u.str, 38) == 0) |
760 | { |
829 | { |
761 | // its an sdcard map |
830 | // its an sdcard map |
762 | // dbg(0,"map name=%s",map_name_attr.u.str); |
831 | // //DBG dbg(0,"map name=%s",map_name_attr.u.str); |
763 | mr=map_rect_new(map, &sel); |
832 | mr = map_rect_new(map, &sel); |
764 | if (mr) |
833 | if (mr) |
765 | { |
834 | { |
766 | //char *streetname_last=NULL; |
835 | //char *streetname_last=NULL; |
767 | |
836 | |
768 | while ((item=map_rect_get_item(mr))) |
837 | while ((item = map_rect_get_item(mr))) |
769 | { |
838 | { |
770 | int label_count=0; |
839 | int label_count = 0; |
771 | char *labels[2]; |
840 | char *labels[2]; |
772 | |
841 | |
773 | // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel); |
842 | // count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, &sel); |
774 | count=item_coord_get_within_selection(item, ca, max, &sel); |
843 | count = item_coord_get_within_selection(item, ca, max, &sel); |
775 | |
|
|
776 | |
844 | |
777 | // count=item_coord_get_within_selection(item, ca, max, &sel); |
845 | // count=item_coord_get_within_selection(item, ca, max, &sel); |
778 | // count=item_coord_get(item, ca, item->type < type_line ? 1: max); |
846 | // count=item_coord_get(item, ca, item->type < type_line ? 1: max); |
779 | if (! count) |
847 | if (!count) |
780 | { |
848 | { |
781 | continue; |
849 | continue; |
782 | } |
850 | } |
783 | //dbg(0,"count 1=%d\n", count); |
851 | ////DBG dbg(0,"count 1=%d\n", count); |
784 | |
852 | |
785 | if (count == max) |
853 | if (count == max) |
786 | { |
854 | { |
787 | //dbg(0,"count overflow!!\n"); |
855 | ////DBG dbg(0,"count overflow!!\n"); |
788 | } |
856 | } |
789 | |
857 | |
790 | struct attr attr_77; |
858 | struct attr attr_77; |
791 | if (item_attr_get(item, attr_flags, &attr_77)) |
859 | if (item_attr_get(item, attr_flags, &attr_77)) |
792 | { |
860 | { |
793 | //dbg(0,"uuuuuuuuuuuuu %s uuuuu %d\n",item_to_name(item->type), attr_77.u.num); |
861 | ////DBG dbg(0,"uuuuuuuuuuuuu %s uuuuu %d\n",item_to_name(item->type), attr_77.u.num); |
794 | item->flags=attr_77.u.num; |
862 | item->flags = attr_77.u.num; |
795 | } |
863 | } |
796 | else |
864 | else |
797 | { |
865 | { |
798 | item->flags=0; |
866 | item->flags = 0; |
799 | } |
867 | } |
800 | |
868 | |
801 | //if (item_is_street(*item)) |
869 | //if (item_is_street(*item)) |
802 | //{ |
870 | //{ |
803 | // int i3; |
871 | // int i3; |
804 | // for (i3 = 0 ; i3 < count ; i3++) |
872 | // for (i3 = 0 ; i3 < count ; i3++) |
805 | // { |
873 | // { |
806 | // if (i3) |
874 | // if (i3) |
807 | // { |
875 | // { |
808 | // dbg(0,"1 x1=%d\n",ca[i3-1].x); |
876 | // //DBG dbg(0,"1 x1=%d\n",ca[i3-1].x); |
809 | // dbg(0,"1 y1=%d\n",ca[i3-1].y); |
877 | // //DBG dbg(0,"1 y1=%d\n",ca[i3-1].y); |
810 | // dbg(0,"1 x2=%d\n",ca[i3].x); |
878 | // //DBG dbg(0,"1 x2=%d\n",ca[i3].x); |
811 | // dbg(0,"1 y2=%d\n",ca[i3].y); |
879 | // //DBG dbg(0,"1 y2=%d\n",ca[i3].y); |
812 | // } |
880 | // } |
813 | // } |
881 | // } |
814 | //} |
882 | //} |
815 | |
883 | |
816 | count=transform(tr, pro, ca, pa, count, 0, 0, NULL); |
884 | count = transform(tr, pro, ca, pa, count, 0, 0, NULL); |
817 | |
885 | |
818 | //dbg(0,"count 2=%d\n", count); |
886 | ////DBG dbg(0,"count 2=%d\n", count); |
819 | |
887 | |
820 | // --- LABEL --- |
888 | // --- LABEL --- |
821 | labels[1]=NULL; |
889 | labels[1] = NULL; |
822 | label_count=0; |
890 | label_count = 0; |
823 | if (item_attr_get(item, attr_label, &attr)) |
891 | if (item_attr_get(item, attr_label, &attr)) |
824 | { |
892 | { |
825 | labels[0]=attr.u.str; |
893 | labels[0] = attr.u.str; |
826 | //dbg(0,"labels[0]=%s\n",attr.u.str); |
894 | ////DBG dbg(0,"labels[0]=%s\n",attr.u.str); |
827 | if (!label_count) |
895 | if (!label_count) |
828 | { |
896 | { |
829 | label_count=2; |
897 | label_count = 2; |
830 | } |
898 | } |
831 | } |
899 | } |
832 | else |
900 | else |
833 | { |
901 | { |
834 | labels[0]=NULL; |
902 | labels[0] = NULL; |
835 | } |
903 | } |
836 | // --- LABEL --- |
904 | // --- LABEL --- |
837 | |
905 | |
838 | if (item_is_street(*item)) |
906 | if (item_is_street(*item)) |
839 | { |
907 | { |
840 | //int i3; |
908 | //int i3; |
841 | //for (i3 = 0 ; i3 < count ; i3++) |
909 | //for (i3 = 0 ; i3 < count ; i3++) |
842 | //{ |
910 | //{ |
843 | // if (i3) |
911 | // if (i3) |
844 | // { |
912 | // { |
845 | // dbg(0,"2 x1=%d\n",pa[i3-1].x); |
913 | // //DBG dbg(0,"2 x1=%d\n",pa[i3-1].x); |
846 | // dbg(0,"2 y1=%d\n",pa[i3-1].y); |
914 | // //DBG dbg(0,"2 y1=%d\n",pa[i3-1].y); |
847 | // dbg(0,"2 x2=%d\n",pa[i3].x); |
915 | // //DBG dbg(0,"2 x2=%d\n",pa[i3].x); |
848 | // dbg(0,"2 y2=%d\n",pa[i3].y); |
916 | // //DBG dbg(0,"2 y2=%d\n",pa[i3].y); |
849 | // } |
917 | // } |
850 | //} |
918 | //} |
851 | android_DrawMapPreview_polyline(pa, count, 0); |
919 | android_DrawMapPreview_polyline(pa, count, 0); |
852 | if (labels[0] != NULL) |
920 | if (labels[0] != NULL) |
853 | { |
921 | { |
854 | map_preview_label_line(pa, count, labels[0], font_size); |
922 | map_preview_label_line(pa, count, labels[0], font_size); |
855 | } |
923 | } |
856 | } |
924 | } |
857 | else if (item_is_district(*item)) |
925 | else if (item_is_district(*item)) |
858 | { |
926 | { |
859 | if (zoom > 6) |
927 | if (zoom > 6) |
|
|
928 | { |
|
|
929 | // //DBG dbg(0,"xx** %s - %s\n",item_to_name(item->type),labels[0]); |
|
|
930 | if (count >= 1) |
860 | { |
931 | { |
861 | // dbg(0,"xx** %s - %s\n",item_to_name(item->type),labels[0]); |
|
|
862 | if (count >= 1) |
|
|
863 | { |
|
|
864 | android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size*2, 0x10000, 0); |
932 | android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 2, 0x10000, 0); |
865 | } |
|
|
866 | } |
933 | } |
|
|
934 | } |
867 | } |
935 | } |
868 | else if (item_is_town(*item)) |
936 | else if (item_is_town(*item)) |
869 | { |
937 | { |
870 | // dbg(0,"yy** %s - %s\n",item_to_name(item->type),labels[0]); |
938 | // //DBG dbg(0,"yy** %s - %s\n",item_to_name(item->type),labels[0]); |
871 | if (count >= 1) |
939 | if (count >= 1) |
872 | { |
940 | { |
873 | android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size*3, 0x10000, 0); |
941 | android_DrawMapPreview_text(pa[0].x, pa[0].y, labels[0], font_size * 3, 0x10000, 0); |
874 | } |
942 | } |
875 | } |
943 | } |
876 | |
944 | |
877 | //if (item_is_street(*item)) |
945 | //if (item_is_street(*item)) |
878 | //{ |
946 | //{ |
879 | // if (item_attr_get(item, attr_label, &attr)) |
947 | // if (item_attr_get(item, attr_label, &attr)) |
880 | // { |
948 | // { |
881 | // //dbg(0,"street1=%s\n",map_convert_string(item->map, attr.u.str)); |
949 | // ////DBG dbg(0,"street1=%s\n",map_convert_string(item->map, attr.u.str)); |
882 | // if ( (streetname_last==NULL) || (strcmp(streetname_last,attr.u.str) != 0) ) |
950 | // if ( (streetname_last==NULL) || (strcmp(streetname_last,attr.u.str) != 0) ) |
883 | // { |
951 | // { |
884 | // //dbg(0,"street2=%s\n",map_convert_string(item->map, attr.u.str)); |
952 | // ////DBG dbg(0,"street2=%s\n",map_convert_string(item->map, attr.u.str)); |
885 | // } |
953 | // } |
886 | // } |
954 | // } |
887 | //} |
955 | //} |
888 | } |
956 | } |
889 | //g_free(streetname_last); |
957 | //g_free(streetname_last); |
… | |
… | |
893 | } |
961 | } |
894 | } |
962 | } |
895 | } |
963 | } |
896 | mapset_close(msh); |
964 | mapset_close(msh); |
897 | |
965 | |
898 | enum projection pro2=transform_get_projection(global_navit->trans_cursor); |
966 | enum projection pro2 = transform_get_projection(global_navit->trans_cursor); |
899 | struct point pnt; |
967 | struct point pnt; |
900 | transform(tr, pro2, &c, &pnt, 1, 0, 0, NULL); |
968 | transform(tr, pro2, &c, &pnt, 1, 0, 0, NULL); |
901 | transform_destroy(tr); |
969 | transform_destroy(tr); |
902 | // ----------------------- big draw loop ----------------------- |
970 | // ----------------------- big draw loop ----------------------- |
903 | // ----------------------- big draw loop ----------------------- |
971 | // ----------------------- big draw loop ----------------------- |
… | |
… | |
905 | // ----------------------- big draw loop ----------------------- |
973 | // ----------------------- big draw loop ----------------------- |
906 | |
974 | |
907 | android_DrawMapPreview_target(pnt.x, pnt.y); |
975 | android_DrawMapPreview_target(pnt.x, pnt.y); |
908 | } |
976 | } |
909 | |
977 | |
910 | void |
|
|
911 | android_DrawMapPreview_target(int x, int y) |
978 | void android_DrawMapPreview_target(int x, int y) |
912 | { |
979 | { |
913 | if (NavitMapPreviewActivityClass==NULL) |
980 | if (NavitMapPreviewActivityClass == NULL) |
914 | { |
981 | { |
915 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
982 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
916 | { |
983 | { |
917 | NavitMapPreviewActivityClass=NULL; |
984 | NavitMapPreviewActivityClass = NULL; |
918 | return; |
985 | return; |
919 | } |
986 | } |
920 | } |
987 | } |
921 | if (DrawMapPreview_target == NULL) |
988 | if (DrawMapPreview_target == NULL) |
922 | { |
989 | { |
923 | android_find_static_method(NavitMapPreviewActivityClass,"DrawMapPreview_target", "(II)V", &DrawMapPreview_target); |
990 | android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_target", "(II)V", &DrawMapPreview_target); |
924 | } |
991 | } |
925 | if (DrawMapPreview_target == NULL) |
992 | if (DrawMapPreview_target == NULL) |
926 | { |
993 | { |
927 | dbg(0,"no method found\n"); |
994 | //DBG dbg(0, "no method found\n"); |
928 | return; /* exception thrown */ |
995 | return; /* exception thrown */ |
929 | } |
996 | } |
930 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_target, x, y); |
997 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_target, x, y); |
931 | } |
998 | } |
932 | |
999 | |
933 | void |
|
|
934 | android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy) |
1000 | void android_DrawMapPreview_text(int x, int y, char *text, int size, int dx, int dy) |
935 | { |
1001 | { |
936 | |
1002 | |
937 | if (NavitMapPreviewActivityClass==NULL) |
1003 | if (NavitMapPreviewActivityClass == NULL) |
938 | { |
1004 | { |
939 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
1005 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
940 | { |
1006 | { |
941 | NavitMapPreviewActivityClass=NULL; |
1007 | NavitMapPreviewActivityClass = NULL; |
942 | return; |
1008 | return; |
943 | } |
1009 | } |
944 | } |
1010 | } |
945 | if (DrawMapPreview_text==NULL) |
|
|
946 | { |
|
|
947 | android_find_static_method(NavitMapPreviewActivityClass,"DrawMapPreview_text", "(IILjava/lang/String;III)V", &DrawMapPreview_text); |
|
|
948 | } |
|
|
949 | if (DrawMapPreview_text == NULL) |
1011 | if (DrawMapPreview_text == NULL) |
950 | { |
1012 | { |
|
|
1013 | android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_text", "(IILjava/lang/String;III)V", &DrawMapPreview_text); |
|
|
1014 | } |
|
|
1015 | if (DrawMapPreview_text == NULL) |
|
|
1016 | { |
951 | dbg(0,"no method found\n"); |
1017 | //DBG dbg(0, "no method found\n"); |
952 | return; /* exception thrown */ |
1018 | return; /* exception thrown */ |
953 | } |
1019 | } |
954 | |
1020 | |
955 | //dbg(0,"** dx=%d,dy=%d\n",dx,dy); |
1021 | ////DBG dbg(0,"** dx=%d,dy=%d\n",dx,dy); |
956 | |
1022 | |
957 | jstring string1 = (*jnienv)->NewStringUTF(jnienv, text); |
1023 | jstring string1 = (*jnienv)->NewStringUTF(jnienv, text); |
958 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_text, x, y, string1, size, dx, dy); |
1024 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_text, x, y, string1, size, dx, dy); |
959 | (*jnienv)->DeleteLocalRef(jnienv, string1); |
1025 | (*jnienv)->DeleteLocalRef(jnienv, string1); |
960 | } |
1026 | } |
961 | |
1027 | |
962 | |
|
|
963 | void |
|
|
964 | android_DrawMapPreview_polyline(struct point *p, int count, int type) |
1028 | void android_DrawMapPreview_polyline(struct point *p, int count, int type) |
965 | { |
1029 | { |
966 | // type: |
1030 | // type: |
967 | // 0 -> normal street |
1031 | // 0 -> normal street |
968 | // 2 -> country border |
1032 | // 2 -> country border |
969 | |
1033 | |
970 | if (NavitMapPreviewActivityClass==NULL) |
1034 | if (NavitMapPreviewActivityClass == NULL) |
971 | { |
1035 | { |
972 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
1036 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitMapPreviewActivity", &NavitMapPreviewActivityClass)) |
973 | { |
1037 | { |
974 | NavitMapPreviewActivityClass=NULL; |
1038 | NavitMapPreviewActivityClass = NULL; |
975 | return; |
1039 | return; |
976 | } |
1040 | } |
977 | } |
1041 | } |
978 | if (DrawMapPreview_polyline==NULL) |
|
|
979 | { |
|
|
980 | android_find_static_method(NavitMapPreviewActivityClass,"DrawMapPreview_polyline", "(I[I)V", &DrawMapPreview_polyline); |
|
|
981 | } |
|
|
982 | if (DrawMapPreview_polyline == NULL) |
1042 | if (DrawMapPreview_polyline == NULL) |
983 | { |
1043 | { |
|
|
1044 | android_find_static_method(NavitMapPreviewActivityClass, "DrawMapPreview_polyline", "(I[I)V", &DrawMapPreview_polyline); |
|
|
1045 | } |
|
|
1046 | if (DrawMapPreview_polyline == NULL) |
|
|
1047 | { |
984 | dbg(0,"no method found\n"); |
1048 | //DBG dbg(0, "no method found\n"); |
985 | return; /* exception thrown */ |
1049 | return; /* exception thrown */ |
986 | } |
1050 | } |
987 | |
1051 | |
988 | jint pc[count*2]; |
1052 | jint pc[count * 2]; |
989 | int i; |
1053 | int i; |
990 | jintArray points; |
1054 | jintArray points; |
991 | if (count <= 0) |
1055 | if (count <= 0) |
992 | { |
1056 | { |
993 | return; |
1057 | return; |
994 | } |
1058 | } |
995 | points = (*jnienv)->NewIntArray(jnienv,count*2); |
1059 | points = (*jnienv)->NewIntArray(jnienv, count * 2); |
996 | for (i = 0 ; i < count ; i++) |
1060 | for (i = 0; i < count; i++) |
997 | { |
1061 | { |
998 | pc[i*2]=p[i].x; |
1062 | pc[i * 2] = p[i].x; |
999 | pc[i*2+1]=p[i].y; |
1063 | pc[i * 2 + 1] = p[i].y; |
1000 | } |
1064 | } |
1001 | (*jnienv)->SetIntArrayRegion(jnienv, points, 0, count*2, pc); |
1065 | (*jnienv)->SetIntArrayRegion(jnienv, points, 0, count * 2, pc); |
1002 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_polyline, type, points); |
1066 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitMapPreviewActivityClass, DrawMapPreview_polyline, type, points); |
1003 | (*jnienv)->DeleteLocalRef(jnienv, points); |
1067 | (*jnienv)->DeleteLocalRef(jnienv, points); |
1004 | } |
1068 | } |
1005 | |
1069 | |
1006 | |
|
|
1007 | |
|
|
1008 | |
|
|
1009 | |
|
|
1010 | |
|
|
1011 | |
|
|
1012 | |
|
|
1013 | JNIEXPORT jstring JNICALL |
1070 | JNIEXPORT jstring JNICALL |
1014 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackGeoCalc( JNIEnv* env, jobject thiz, int i, float a, float b) |
1071 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackGeoCalc(JNIEnv* env, jobject thiz, int i, float a, float b) |
1015 | { |
1072 | { |
|
|
1073 | // dbg(0,"EEnter i=%d\n", i); |
|
|
1074 | |
1016 | // const char *result; |
1075 | // const char *result; |
1017 | gchar *result; |
1076 | gchar *result; |
1018 | |
1077 | |
1019 | if (i == 1) |
1078 | if (i == 1) |
1020 | { |
1079 | { |
1021 | // pixel-on-screen to geo |
1080 | // pixel-on-screen to geo |
1022 | struct coord_geo g22; |
1081 | struct coord_geo g22; |
1023 | struct coord c22; |
1082 | struct coord c22; |
1024 | struct point p; |
1083 | struct point p; |
1025 | p.x=a; |
1084 | p.x = a; |
1026 | p.y=b; |
1085 | p.y = b; |
1027 | transform_reverse(global_navit->trans, &p, &c22); |
1086 | transform_reverse(global_navit->trans, &p, &c22); |
1028 | //dbg(0,"%f, %f\n",a, b); |
1087 | ////DBG dbg(0,"%f, %f\n",a, b); |
1029 | //dbg(0,"%d, %d\n",p.x, p.y); |
1088 | ////DBG dbg(0,"%d, %d\n",p.x, p.y); |
1030 | transform_to_geo(projection_mg, &c22, &g22); |
1089 | transform_to_geo(projection_mg, &c22, &g22); |
1031 | //dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng); |
1090 | ////DBG dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng); |
1032 | result=g_strdup_printf("%f:%f",g22.lat,g22.lng); |
1091 | result = g_strdup_printf("%f:%f", g22.lat, g22.lng); |
1033 | } |
1092 | } |
1034 | else if (i == 2) |
1093 | else if (i == 2) |
1035 | { |
1094 | { |
1036 | // geo to pixel-on-screen |
1095 | // geo to pixel-on-screen |
1037 | struct coord c99; |
1096 | struct coord c99; |
1038 | struct coord_geo g99; |
1097 | struct coord_geo g99; |
1039 | g99.lat=a; |
1098 | g99.lat = a; |
1040 | g99.lng=b; |
1099 | g99.lng = b; |
1041 | //dbg(0,"zzzzz %f, %f\n",a, b); |
1100 | ////DBG dbg(0,"zzzzz %f, %f\n",a, b); |
1042 | //dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); |
1101 | ////DBG dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); |
1043 | transform_from_geo(projection_mg, &g99, &c99); |
1102 | transform_from_geo(projection_mg, &g99, &c99); |
1044 | //dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); |
1103 | ////DBG dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); |
1045 | |
1104 | |
1046 | enum projection pro=transform_get_projection(global_navit->trans_cursor); |
1105 | enum projection pro = transform_get_projection(global_navit->trans_cursor); |
1047 | struct point pnt; |
1106 | struct point pnt; |
1048 | transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); |
1107 | transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); |
1049 | //dbg(0,"x=%d\n",pnt.x); |
1108 | ////DBG dbg(0,"x=%d\n",pnt.x); |
1050 | //dbg(0,"y=%d\n",pnt.y); |
1109 | ////DBG dbg(0,"y=%d\n",pnt.y); |
1051 | |
1110 | |
1052 | result=g_strdup_printf("%d:%d",pnt.x,pnt.y); |
1111 | result = g_strdup_printf("%d:%d", pnt.x, pnt.y); |
1053 | } |
1112 | } |
1054 | else if (i == 3) |
1113 | else if (i == 3) |
1055 | { |
1114 | { |
1056 | // show lat,lng position on screen center |
1115 | // show lat,lng position on screen center |
1057 | struct coord c99; |
1116 | struct coord c99; |
1058 | struct pcoord pc99; |
1117 | struct pcoord pc99; |
1059 | struct coord_geo g99; |
1118 | struct coord_geo g99; |
1060 | g99.lat=a; |
1119 | g99.lat = a; |
1061 | g99.lng=b; |
1120 | g99.lng = b; |
1062 | //dbg(0,"zzzzz %f, %f\n",a, b); |
1121 | ////DBG dbg(0,"zzzzz %f, %f\n",a, b); |
1063 | //dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); |
1122 | ////DBG dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); |
1064 | transform_from_geo(projection_mg, &g99, &c99); |
1123 | transform_from_geo(projection_mg, &g99, &c99); |
1065 | //dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); |
1124 | ////DBG dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); |
1066 | |
1125 | |
1067 | //enum projection pro=transform_get_projection(global_navit->trans_cursor); |
1126 | //enum projection pro=transform_get_projection(global_navit->trans_cursor); |
1068 | //struct point pnt; |
1127 | //struct point pnt; |
1069 | //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); |
1128 | //transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); |
1070 | //dbg(0,"x=%d\n",pnt.x); |
1129 | ////DBG dbg(0,"x=%d\n",pnt.x); |
1071 | //dbg(0,"y=%d\n",pnt.y); |
1130 | ////DBG dbg(0,"y=%d\n",pnt.y); |
1072 | pc99.x=c99.x; |
1131 | pc99.x = c99.x; |
1073 | pc99.y=c99.y; |
1132 | pc99.y = c99.y; |
1074 | pc99.pro=projection_mg; |
1133 | pc99.pro = projection_mg; |
1075 | |
1134 | |
1076 | navit_set_center(global_navit, &pc99, 0); |
1135 | navit_set_center(global_navit, &pc99, 0); |
1077 | |
1136 | |
1078 | result=g_strdup_printf("1:1"); |
1137 | result = g_strdup_printf("1:1"); |
1079 | } |
1138 | } |
|
|
1139 | else if (i == 4) |
|
|
1140 | { |
|
|
1141 | // return current target (the end point, not waypoints) |
|
|
1142 | struct coord_geo g22; |
|
|
1143 | struct pcoord c22; |
|
|
1144 | struct coord c99; |
1080 | |
1145 | |
|
|
1146 | c22 = global_navit->destination; |
|
|
1147 | c99.x = c22.x; |
|
|
1148 | c99.y = c22.y; |
|
|
1149 | |
|
|
1150 | transform_to_geo(projection_mg, &c99, &g22); |
|
|
1151 | result = g_strdup_printf("%f:%f", g22.lat, g22.lng); |
|
|
1152 | } |
|
|
1153 | |
1081 | //dbg(0,"result=%s\n", result); |
1154 | // dbg(0, "result=%s\n", result); |
1082 | jstring js = (*env)->NewStringUTF(env,result); |
1155 | jstring js = (*env)->NewStringUTF(env, result); |
1083 | g_free(result); |
1156 | g_free(result); |
1084 | |
1157 | |
1085 | return js; |
1158 | return js; |
1086 | } |
1159 | } |
1087 | |
1160 | |
1088 | JNIEXPORT jstring JNICALL |
1161 | JNIEXPORT jstring JNICALL |
1089 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackLocalizedString( JNIEnv* env, jobject thiz, jobject str) |
1162 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackLocalizedString(JNIEnv* env, jobject thiz, jobject str) |
1090 | { |
1163 | { |
|
|
1164 | //DBG dbg(0,"EEnter\n"); |
|
|
1165 | |
1091 | const char *s; |
1166 | const char *s; |
1092 | const char *localized_str; |
1167 | const char *localized_str; |
1093 | |
1168 | |
1094 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1169 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1095 | //dbg(0,"*****string=%s\n",s); |
1170 | ////DBG dbg(0,"*****string=%s\n",s); |
1096 | |
1171 | |
1097 | localized_str=gettext(s); |
1172 | localized_str = gettext(s); |
1098 | //dbg(0,"localized string=%s",localized_str); |
1173 | ////DBG dbg(0,"localized string=%s",localized_str); |
1099 | |
1174 | |
1100 | // jstring dataStringValue = (jstring) localized_str; |
1175 | // jstring dataStringValue = (jstring) localized_str; |
1101 | jstring js = (*env)->NewStringUTF(env,localized_str); |
1176 | jstring js = (*env)->NewStringUTF(env, localized_str); |
1102 | |
1177 | |
1103 | (*env)->ReleaseStringUTFChars(env, str, s); |
1178 | (*env)->ReleaseStringUTFChars(env, str, s); |
1104 | |
1179 | |
1105 | return js; |
1180 | return js; |
1106 | } |
1181 | } |
1107 | |
1182 | |
1108 | JNIEXPORT void JNICALL |
1183 | JNIEXPORT void JNICALL |
1109 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackMessageChannel( JNIEnv* env, jobject thiz, int i, jobject str) |
1184 | Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackMessageChannel(JNIEnv* env, jobject thiz, int i, jobject str2) |
1110 | { |
1185 | { |
1111 | const char *s; |
1186 | const char *s; |
1112 | //dbg(0,"enter %p %p\n",(struct callback *)i,str); |
1187 | jobject str = (*env)->NewGlobalRef(env, str2); |
|
|
1188 | |
|
|
1189 | //DBG dbg(0,"enter %d %p\n",i,str); |
1113 | |
1190 | |
1114 | config_get_attr(config, attr_navit, &attr, NULL); |
1191 | config_get_attr(config, attr_navit, &attr, NULL); |
1115 | // attr.u.navit |
1192 | // attr.u.navit |
|
|
1193 | |
|
|
1194 | //DBG dbg(0,"c1\n"); |
1116 | |
1195 | |
1117 | if (i) |
1196 | if (i) |
1118 | { |
1197 | { |
1119 | if (i == 1) |
1198 | if (i == 1) |
1120 | { |
1199 | { |
… | |
… | |
1126 | { |
1205 | { |
1127 | // zoom out |
1206 | // zoom out |
1128 | navit_zoom_out_cursor(global_navit, 2); |
1207 | navit_zoom_out_cursor(global_navit, 2); |
1129 | // navit_zoom_out_cursor(attr.u.navit, 2); |
1208 | // navit_zoom_out_cursor(attr.u.navit, 2); |
1130 | } |
1209 | } |
|
|
1210 | else if (i == 58) |
|
|
1211 | { |
|
|
1212 | // make street search radius bigger to the factor "s" |
|
|
1213 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1214 | global_search_street_size_factor = atoi(s); |
|
|
1215 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1216 | } |
|
|
1217 | else if (i == 57) |
|
|
1218 | { |
|
|
1219 | // keep drawing streets as if at "order" level xxx |
|
|
1220 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1221 | limit_order_corrected = atoi(s); |
|
|
1222 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1223 | } |
|
|
1224 | else if (i == 56) |
|
|
1225 | { |
|
|
1226 | // draw polylines with/without circles at the end |
|
|
1227 | //dbg(0, "dpf1\n"); |
|
|
1228 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1229 | //dbg(0, "dpf2\n"); |
|
|
1230 | draw_polylines_fast = atoi(s); |
|
|
1231 | //dbg(0, "dpf=%d\n", draw_polylines_fast); |
|
|
1232 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1233 | } |
|
|
1234 | else if (i == 55) |
|
|
1235 | { |
|
|
1236 | // set cache size for (map-)files |
|
|
1237 | dbg(0, "csf1\n"); |
|
|
1238 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1239 | dbg(0, "csf2\n"); |
|
|
1240 | cache_size_file = atoi(s); |
|
|
1241 | file_cache_init(); |
|
|
1242 | dbg(0, "csf=%d\n", cache_size_file); |
|
|
1243 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1244 | } |
|
|
1245 | else if (i == 54) |
|
|
1246 | { |
|
|
1247 | // speak streetnames |
|
|
1248 | global_speak_streetnames = 1; |
|
|
1249 | } |
|
|
1250 | else if (i == 53) |
|
|
1251 | { |
|
|
1252 | // dont speak streetnames |
|
|
1253 | global_speak_streetnames = 0; |
|
|
1254 | } |
|
|
1255 | else if (i == 52) |
|
|
1256 | { |
|
|
1257 | // switch to demo vehicle |
|
|
1258 | if (global_navit->vehicle) |
|
|
1259 | { |
|
|
1260 | navit_remove_cursors(global_navit); |
|
|
1261 | vehicle_destroy(global_navit->vehicle->vehicle); |
|
|
1262 | global_navit->vehicles = NULL; |
|
|
1263 | global_navit->vehicle = NULL; |
|
|
1264 | } |
|
|
1265 | |
|
|
1266 | struct attr parent; |
|
|
1267 | struct attr source; |
|
|
1268 | struct attr active; |
|
|
1269 | struct attr follow; |
|
|
1270 | struct attr speed; |
|
|
1271 | struct attr interval; |
|
|
1272 | struct attr *attrs[6]; |
|
|
1273 | parent.type = attr_navit; |
|
|
1274 | parent.u.navit = global_navit; |
|
|
1275 | |
|
|
1276 | source.type = attr_source; |
|
|
1277 | source.u.str = "demo://"; |
|
|
1278 | |
|
|
1279 | active.type = attr_active; |
|
|
1280 | active.u.num = 1; |
|
|
1281 | |
|
|
1282 | follow.type = attr_follow; |
|
|
1283 | follow.u.num = 1; |
|
|
1284 | |
|
|
1285 | speed.type = attr_speed; |
|
|
1286 | speed.u.num = 45; |
|
|
1287 | |
|
|
1288 | interval.type = attr_interval; |
|
|
1289 | interval.u.num = 1000; |
|
|
1290 | |
|
|
1291 | attrs[0] = &source; |
|
|
1292 | attrs[1] = &active; |
|
|
1293 | attrs[2] = &follow; |
|
|
1294 | attrs[3] = &speed; |
|
|
1295 | attrs[4] = &interval; |
|
|
1296 | attrs[5] = NULL; |
|
|
1297 | // attr_source -> source->u.str='demo://' |
|
|
1298 | // <!-- vehicle name="Demo" profilename="car" enabled="no" active="yes" source="demo://" --> |
|
|
1299 | struct vehicle *v; |
|
|
1300 | //DBG dbg(0, "demo vehicle new start\n"); |
|
|
1301 | v = vehicle_new(&parent, attrs); |
|
|
1302 | //DBG dbg(0, "demo vehicle new end\n"); |
|
|
1303 | |
|
|
1304 | if (v != NULL) |
|
|
1305 | { |
|
|
1306 | //DBG dbg(0, "adding demo vehicle\n"); |
|
|
1307 | navit_add_vehicle(global_navit, v); |
|
|
1308 | //DBG dbg(0, "setting cursor\n"); |
|
|
1309 | navit_set_cursors(global_navit); |
|
|
1310 | |
|
|
1311 | struct attr follow2; |
|
|
1312 | follow2.type = attr_follow; |
|
|
1313 | follow2.u.num = 1; |
|
|
1314 | navit_set_attr(global_navit, &follow2); |
|
|
1315 | |
|
|
1316 | // switch "Map follows Vehicle" ON |
|
|
1317 | struct attr attrx; |
|
|
1318 | attrx.type = attr_follow_cursor; |
|
|
1319 | attrx.u.num = 1; |
|
|
1320 | navit_set_attr(global_navit, &attrx); |
|
|
1321 | } |
|
|
1322 | else |
|
|
1323 | { |
|
|
1324 | //DBG dbg(0, "ERROR adding demo vehicle\n"); |
|
|
1325 | } |
|
|
1326 | // **no** navit_set_vehicle(global_navit, global_navit->vehicle); |
|
|
1327 | //DBG dbg(0, "ready\n"); |
|
|
1328 | } |
|
|
1329 | else if (i == 51) |
|
|
1330 | { |
|
|
1331 | // set position to pixel x,y |
|
|
1332 | //DBG dbg(0, "sp 1\n"); |
|
|
1333 | char *pstr; |
|
|
1334 | struct point p; |
|
|
1335 | struct coord c; |
|
|
1336 | struct pcoord pc; |
|
|
1337 | |
|
|
1338 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1339 | char parse_str[strlen(s) + 1]; |
|
|
1340 | strcpy(parse_str, s); |
|
|
1341 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1342 | |
|
|
1343 | // (pixel-x#pixel-y) |
|
|
1344 | // pixel-x |
|
|
1345 | pstr = strtok(parse_str, "#"); |
|
|
1346 | p.x = atoi(pstr); |
|
|
1347 | // pixel-y |
|
|
1348 | pstr = strtok(NULL, "#"); |
|
|
1349 | p.y = atoi(pstr); |
|
|
1350 | |
|
|
1351 | //DBG dbg(0, "sp 2\n"); |
|
|
1352 | transform_reverse(global_navit->trans, &p, &c); |
|
|
1353 | //DBG dbg(0, "sp 3\n"); |
|
|
1354 | |
|
|
1355 | pc.x = c.x; |
|
|
1356 | pc.y = c.y; |
|
|
1357 | //DBG dbg(0, "sp 4\n"); |
|
|
1358 | pc.pro = transform_get_projection(global_navit->trans); |
|
|
1359 | //DBG dbg(0, "sp 5\n"); |
|
|
1360 | |
|
|
1361 | //DBG dbg(0, "%d %d\n", pc.x, pc.y); |
|
|
1362 | // set position |
|
|
1363 | //DBG dbg(0, "sp 6\n"); |
|
|
1364 | navit_set_position(global_navit, &pc); |
|
|
1365 | //DBG dbg(0, "ready\n"); |
|
|
1366 | } |
|
|
1367 | else if (i == 50) |
|
|
1368 | { |
|
|
1369 | // we request to stop drawing the map |
|
|
1370 | // //DBG dbg(0, "cancel_drawing_global=1\n"); |
|
|
1371 | cancel_drawing_global = 1; |
|
|
1372 | } |
|
|
1373 | else if (i == 47) |
|
|
1374 | { |
|
|
1375 | // change maps data dir |
|
|
1376 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1377 | navit_maps_dir = g_strdup(s); |
|
|
1378 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1379 | // //DBG dbg(0,"*****string use=%s\n",navit_maps_dir); |
|
|
1380 | } |
1131 | else if (i == 46) |
1381 | else if (i == 46) |
1132 | { |
1382 | { |
1133 | // stop searching and show results found until now |
1383 | // stop searching and show results found until now |
1134 | offline_search_break_searching=1; |
1384 | offline_search_break_searching = 1; |
1135 | } |
1385 | } |
1136 | else if (i == 45) |
1386 | else if (i == 45) |
1137 | { |
1387 | { |
1138 | // filter duplicates in search results |
1388 | // filter duplicates in search results |
1139 | offline_search_filter_duplicates=1; |
1389 | offline_search_filter_duplicates = 1; |
1140 | } |
1390 | } |
1141 | else if (i == 44) |
1391 | else if (i == 44) |
1142 | { |
1392 | { |
1143 | // show duplicates in search results |
1393 | // show duplicates in search results |
1144 | offline_search_filter_duplicates=0; |
1394 | offline_search_filter_duplicates = 0; |
1145 | } |
1395 | } |
1146 | else if (i == 43) |
1396 | else if (i == 43) |
1147 | { |
1397 | { |
1148 | // routing mode "normal roads" |
1398 | // routing mode "normal roads" |
1149 | routing_mode=1; |
1399 | routing_mode = 1; |
1150 | } |
1400 | } |
1151 | else if (i == 42) |
1401 | else if (i == 42) |
1152 | { |
1402 | { |
1153 | // routing mode "highways" |
1403 | // routing mode "highways" |
1154 | routing_mode=0; |
1404 | routing_mode = 0; |
1155 | } |
1405 | } |
1156 | else if (i == 41) |
1406 | else if (i == 41) |
1157 | { |
1407 | { |
1158 | // switch "Map follows Vehicle" OFF |
1408 | // switch "Map follows Vehicle" OFF |
1159 | struct attr attrx; |
1409 | struct attr attrx; |
1160 | attrx.type=attr_follow_cursor; |
1410 | attrx.type = attr_follow_cursor; |
1161 | attrx.u.num=0; |
1411 | attrx.u.num = 0; |
1162 | navit_set_attr(global_navit,&attrx); |
1412 | navit_set_attr(global_navit, &attrx); |
1163 | } |
1413 | } |
1164 | else if (i == 40) |
1414 | else if (i == 40) |
1165 | { |
1415 | { |
1166 | // switch "Map follows Vehicle" ON |
1416 | // switch "Map follows Vehicle" ON |
1167 | struct attr attrx; |
1417 | struct attr attrx; |
1168 | attrx.type=attr_follow_cursor; |
1418 | attrx.type = attr_follow_cursor; |
1169 | attrx.u.num=1; |
1419 | attrx.u.num = 1; |
1170 | navit_set_attr(global_navit,&attrx); |
1420 | navit_set_attr(global_navit, &attrx); |
1171 | } |
1421 | } |
1172 | else if (i == 39) |
1422 | else if (i == 39) |
1173 | { |
1423 | { |
1174 | // switch "Northing" OFF |
1424 | // switch "Northing" OFF |
1175 | struct attr attrx; |
1425 | struct attr attrx; |
1176 | attrx.type=attr_orientation; |
1426 | attrx.type = attr_orientation; |
1177 | attrx.u.num=0; |
1427 | attrx.u.num = 0; |
1178 | navit_set_attr(global_navit,&attrx); |
1428 | navit_set_attr(global_navit, &attrx); |
1179 | } |
1429 | } |
1180 | else if (i == 38) |
1430 | else if (i == 38) |
1181 | { |
1431 | { |
1182 | // switch "Northing" ON |
1432 | // switch "Northing" ON |
1183 | struct attr attrx; |
1433 | struct attr attrx; |
1184 | attrx.type=attr_orientation; |
1434 | attrx.type = attr_orientation; |
1185 | attrx.u.num=1; |
1435 | attrx.u.num = 1; |
1186 | navit_set_attr(global_navit,&attrx); |
1436 | navit_set_attr(global_navit, &attrx); |
1187 | } |
1437 | } |
1188 | else if (i == 37) |
1438 | else if (i == 37) |
1189 | { |
1439 | { |
1190 | // switch "Lock on road" OFF |
1440 | // switch "Lock on road" OFF |
1191 | struct attr attrx; |
1441 | struct attr attrx; |
1192 | attrx.type=attr_tracking; |
1442 | attrx.type = attr_tracking; |
1193 | attrx.u.num=0; |
1443 | attrx.u.num = 0; |
1194 | navit_set_attr(global_navit,&attrx); |
1444 | navit_set_attr(global_navit, &attrx); |
1195 | } |
1445 | } |
1196 | else if (i == 36) |
1446 | else if (i == 36) |
1197 | { |
1447 | { |
1198 | // switch "Lock on road" ON |
1448 | // switch "Lock on road" ON |
1199 | struct attr attrx; |
1449 | struct attr attrx; |
1200 | attrx.type=attr_tracking; |
1450 | attrx.type = attr_tracking; |
1201 | attrx.u.num=1; |
1451 | attrx.u.num = 1; |
1202 | navit_set_attr(global_navit,&attrx); |
1452 | navit_set_attr(global_navit, &attrx); |
1203 | } |
1453 | } |
1204 | else if (i == 35) |
1454 | else if (i == 35) |
1205 | { |
1455 | { |
1206 | // announcer voice ON |
1456 | // announcer voice ON |
1207 | navit_cmd_announcer_on(global_navit); |
1457 | navit_cmd_announcer_on(global_navit); |
… | |
… | |
1212 | navit_cmd_announcer_off(global_navit); |
1462 | navit_cmd_announcer_off(global_navit); |
1213 | } |
1463 | } |
1214 | else if (i == 33) |
1464 | else if (i == 33) |
1215 | { |
1465 | { |
1216 | // zoom to specific zoomlevel |
1466 | // zoom to specific zoomlevel |
1217 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1467 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1218 | int zoom_level = atoi(s); |
1468 | int zoom_level = atoi(s); |
1219 | navit_zoom_to_scale(global_navit, zoom_level); |
1469 | navit_zoom_to_scale(global_navit, zoom_level); |
1220 | (*env)->ReleaseStringUTFChars(env, str, s); |
1470 | (*env)->ReleaseStringUTFChars(env, str, s); |
1221 | } |
1471 | } |
1222 | else if (i == 32) |
1472 | else if (i == 32) |
1223 | { |
1473 | { |
1224 | // switch to specific 3D pitch |
1474 | // switch to specific 3D pitch |
1225 | struct attr pitch_attr; |
1475 | struct attr pitch_attr; |
1226 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1476 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1227 | pitch_attr.type=attr_pitch; |
1477 | pitch_attr.type = attr_pitch; |
1228 | pitch_attr.u.num = atoi(s); |
1478 | pitch_attr.u.num = atoi(s); |
1229 | navit_set_attr(global_navit,&pitch_attr); |
1479 | navit_set_attr(global_navit, &pitch_attr); |
1230 | (*env)->ReleaseStringUTFChars(env, str, s); |
1480 | (*env)->ReleaseStringUTFChars(env, str, s); |
1231 | } |
1481 | } |
1232 | else if (i == 31) |
1482 | else if (i == 31) |
1233 | { |
1483 | { |
1234 | // switch to 3D |
1484 | // switch to 3D |
1235 | struct attr pitch_attr; |
1485 | struct attr pitch_attr; |
1236 | pitch_attr.type=attr_pitch; |
1486 | pitch_attr.type = attr_pitch; |
1237 | pitch_attr.u.num=30; |
1487 | pitch_attr.u.num = 30; |
1238 | navit_set_attr(global_navit,&pitch_attr); |
1488 | navit_set_attr(global_navit, &pitch_attr); |
1239 | } |
1489 | } |
1240 | else if (i == 30) |
1490 | else if (i == 30) |
1241 | { |
1491 | { |
1242 | // switch to 2D |
1492 | // switch to 2D |
1243 | struct attr pitch_attr; |
1493 | struct attr pitch_attr; |
1244 | pitch_attr.type=attr_pitch; |
1494 | pitch_attr.type = attr_pitch; |
1245 | pitch_attr.u.num=0; |
1495 | pitch_attr.u.num = 0; |
1246 | navit_set_attr(global_navit,&pitch_attr); |
1496 | navit_set_attr(global_navit, &pitch_attr); |
1247 | } |
1497 | } |
1248 | // 21 - 25 are used in java, so leave a hole here to make it easier to understand |
1498 | // 21 - 25 are used in java, so leave a hole here to make it easier to understand |
|
|
1499 | |
1249 | else if (i == 20) |
1500 | else if (i == 20) |
1250 | { |
1501 | { |
1251 | // add all scdard maps |
1502 | // add all scdard maps |
1252 | navit_add_all_maps(global_navit); |
1503 | navit_add_all_maps(global_navit); |
1253 | } |
1504 | } |
… | |
… | |
1267 | navit_zoom_to_route(global_navit, 0); |
1518 | navit_zoom_to_route(global_navit, 0); |
1268 | } |
1519 | } |
1269 | else if (i == 16) |
1520 | else if (i == 16) |
1270 | { |
1521 | { |
1271 | // use imperial units |
1522 | // use imperial units |
1272 | global_navit->imperial=1; |
1523 | global_navit->imperial = 1; |
1273 | } |
1524 | } |
1274 | else if (i == 15) |
1525 | else if (i == 15) |
1275 | { |
1526 | { |
1276 | // use metric units |
1527 | // use metric units |
1277 | global_navit->imperial=0; |
1528 | global_navit->imperial = 0; |
1278 | } |
1529 | } |
1279 | else if (i == 14) |
1530 | else if (i == 14) |
1280 | { |
1531 | { |
1281 | // draw location of self (car) in the screen center |
1532 | // draw location of self (car) in the screen center |
1282 | global_navit->radius=0; |
1533 | global_navit->radius = 0; |
1283 | } |
1534 | } |
1284 | else if (i == 13) |
1535 | else if (i == 13) |
1285 | { |
1536 | { |
1286 | // draw location of self (car) 30% lower than screen center |
1537 | // draw location of self (car) 30% lower than screen center |
1287 | global_navit->radius=30; |
1538 | global_navit->radius = 30; |
1288 | } |
1539 | } |
1289 | else if (i == 12) |
1540 | else if (i == 12) |
1290 | { |
1541 | { |
1291 | // draw map only at speeds higher than 5 km/h |
1542 | // draw map only at speeds higher than 5 km/h |
1292 | struct attr static_speed_attr; |
1543 | struct attr static_speed_attr; |
1293 | static_speed_attr.type=attr_static_speed; |
1544 | static_speed_attr.type = attr_static_speed; |
1294 | static_speed_attr.u.num=5; |
1545 | static_speed_attr.u.num = 5; |
1295 | vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr); |
1546 | vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr); |
1296 | } |
1547 | } |
1297 | else if (i == 11) |
1548 | else if (i == 11) |
1298 | { |
1549 | { |
1299 | // allow redraw map at ZERO speed |
1550 | // allow redraw map at ZERO speed |
1300 | struct attr static_speed_attr; |
1551 | struct attr static_speed_attr; |
1301 | static_speed_attr.type=attr_static_speed; |
1552 | static_speed_attr.type = attr_static_speed; |
1302 | static_speed_attr.u.num=0; |
1553 | static_speed_attr.u.num = 0; |
1303 | vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr); |
1554 | vehicleprofile_set_attr(global_navit->vehicleprofile, &static_speed_attr); |
1304 | } |
1555 | } |
1305 | else if (i == 10) |
1556 | else if (i == 10) |
1306 | { |
1557 | { |
1307 | // allow internal GUI |
1558 | // allow internal GUI |
… | |
… | |
1313 | allow_gui_internal = 0; |
1564 | allow_gui_internal = 0; |
1314 | } |
1565 | } |
1315 | else if (i == 8) |
1566 | else if (i == 8) |
1316 | { |
1567 | { |
1317 | // zoom to zoomlevel |
1568 | // zoom to zoomlevel |
1318 | // navit_zoom_to_scale(global_navit, 262144); |
1569 | //DBG dbg(0,"-8- a\n"); |
1319 | navit_zoom_to_scale(global_navit, 524288); |
1570 | navit_zoom_to_scale(global_navit, 524288); |
|
|
1571 | //DBG dbg(0,"-8- b\n"); |
1320 | } |
1572 | } |
1321 | else if (i == 7) |
1573 | else if (i == 7) |
1322 | { |
1574 | { |
1323 | // stop navigation |
1575 | // stop navigation |
1324 | if (attr.u.navit->destination_valid != 0) |
1576 | if (attr.u.navit->destination_valid != 0) |
1325 | { |
1577 | { |
1326 | navit_set_destination(&attr.u.navit->self, NULL, NULL, 0); |
1578 | navit_set_destination(&attr.u.navit->self, NULL, NULL, 0); |
1327 | } |
1579 | } |
1328 | } |
1580 | } |
1329 | else if (i==6) |
1581 | else if (i == 6) |
1330 | { |
1582 | { |
1331 | // not used now! |
1583 | // not used now! |
1332 | } |
1584 | } |
1333 | else if (i==5) |
1585 | else if (i == 5) |
1334 | { |
1586 | { |
1335 | // call a command (like in gui) --> seems not many commands really work with this :-( |
1587 | // call a command (like in gui) --> seems not many commands really work with this :-( |
1336 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1588 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1337 | //dbg(0,"*****string=%s\n",s); |
1589 | ////DBG dbg(0,"*****string=%s\n",s); |
1338 | command_evaluate(&attr.u.navit->self,s); |
1590 | command_evaluate(&attr.u.navit->self, s); |
1339 | (*env)->ReleaseStringUTFChars(env, str, s); |
1591 | (*env)->ReleaseStringUTFChars(env, str, s); |
1340 | } |
1592 | } |
1341 | else if (i == 4) |
1593 | else if (i == 49) |
1342 | { |
1594 | { |
1343 | // set destination to pixel x,y on screen |
1595 | // add waypoint at pixel x,y on screen |
1344 | |
1596 | |
1345 | char *pstr; |
1597 | char *pstr; |
1346 | struct point p; |
1598 | struct point p; |
1347 | struct coord c; |
1599 | struct coord c; |
1348 | struct pcoord pc; |
1600 | struct pcoord pc; |
1349 | |
1601 | |
1350 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1602 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1351 | char parse_str[strlen(s) + 1]; |
1603 | char parse_str[strlen(s) + 1]; |
1352 | strcpy(parse_str, s); |
1604 | strcpy(parse_str, s); |
1353 | (*env)->ReleaseStringUTFChars(env, str, s); |
1605 | (*env)->ReleaseStringUTFChars(env, str, s); |
1354 | //dbg(0,"*****string=%s\n",parse_str); |
|
|
1355 | |
1606 | |
1356 | // set destination to (pixel-x#pixel-y) |
1607 | // add waypoint (pixel-x#pixel-y) |
1357 | // pixel-x |
1608 | // pixel-x |
1358 | pstr = strtok (parse_str,"#"); |
1609 | pstr = strtok(parse_str, "#"); |
1359 | p.x = atoi(pstr); |
1610 | p.x = atoi(pstr); |
1360 | // pixel-y |
1611 | // pixel-y |
1361 | pstr = strtok (NULL, "#"); |
1612 | pstr = strtok(NULL, "#"); |
1362 | p.y = atoi(pstr); |
1613 | p.y = atoi(pstr); |
1363 | |
1614 | |
1364 | //dbg(0,"11x=%d\n",p.x); |
|
|
1365 | //dbg(0,"11y=%d\n",p.y); |
|
|
1366 | |
|
|
1367 | transform_reverse(global_navit->trans, &p, &c); |
1615 | transform_reverse(global_navit->trans, &p, &c); |
1368 | |
|
|
1369 | |
1616 | |
1370 | pc.x = c.x; |
1617 | pc.x = c.x; |
1371 | pc.y = c.y; |
1618 | pc.y = c.y; |
1372 | pc.pro = transform_get_projection(global_navit->trans); |
1619 | pc.pro = transform_get_projection(global_navit->trans); |
1373 | |
1620 | |
1374 | //dbg(0,"22x=%d\n",pc.x); |
1621 | // append new waypoint to navigation |
1375 | //dbg(0,"22y=%d\n",pc.y); |
|
|
1376 | |
|
|
1377 | // start navigation asynchronous |
|
|
1378 | navit_set_destination(global_navit, &pc, parse_str, 1); |
1622 | navit_add_waypoint_to_route(global_navit, &pc, parse_str, 1); |
1379 | } |
1623 | } |
1380 | else if (i == 3) |
1624 | else if (i == 4) |
1381 | { |
1625 | { |
1382 | // set destination to lat, lng |
1626 | // set destination to pixel x,y on screen |
1383 | |
1627 | |
1384 | char *name; |
1628 | char *pstr; |
|
|
1629 | struct point p; |
|
|
1630 | struct coord c; |
|
|
1631 | struct pcoord pc; |
|
|
1632 | |
1385 | s=(*env)->GetStringUTFChars(env, str, NULL); |
1633 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1386 | char parse_str[strlen(s) + 1]; |
1634 | char parse_str[strlen(s) + 1]; |
1387 | strcpy(parse_str, s); |
1635 | strcpy(parse_str, s); |
1388 | (*env)->ReleaseStringUTFChars(env, str, s); |
1636 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1637 | |
|
|
1638 | // set destination to (pixel-x#pixel-y) |
|
|
1639 | // pixel-x |
|
|
1640 | pstr = strtok(parse_str, "#"); |
|
|
1641 | p.x = atoi(pstr); |
|
|
1642 | // pixel-y |
|
|
1643 | pstr = strtok(NULL, "#"); |
|
|
1644 | p.y = atoi(pstr); |
|
|
1645 | |
|
|
1646 | transform_reverse(global_navit->trans, &p, &c); |
|
|
1647 | |
|
|
1648 | pc.x = c.x; |
|
|
1649 | pc.y = c.y; |
|
|
1650 | pc.pro = transform_get_projection(global_navit->trans); |
|
|
1651 | |
|
|
1652 | // start navigation asynchronous |
|
|
1653 | navit_set_destination(global_navit, &pc, parse_str, 1); |
|
|
1654 | } |
|
|
1655 | else if (i == 48) |
|
|
1656 | { |
|
|
1657 | // append waypoint at lat, lng |
|
|
1658 | |
|
|
1659 | char *name; |
|
|
1660 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1661 | char parse_str[strlen(s) + 1]; |
|
|
1662 | strcpy(parse_str, s); |
|
|
1663 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1664 | |
|
|
1665 | // waypoint (lat#lon#title) |
|
|
1666 | struct coord_geo g; |
|
|
1667 | char *p; |
|
|
1668 | char *stopstring; |
|
|
1669 | |
|
|
1670 | // lat |
|
|
1671 | p = strtok(parse_str, "#"); |
|
|
1672 | g.lat = strtof(p, &stopstring); |
|
|
1673 | // lon |
|
|
1674 | p = strtok(NULL, "#"); |
|
|
1675 | g.lng = strtof(p, &stopstring); |
|
|
1676 | // description |
|
|
1677 | name = strtok(NULL, "#"); |
|
|
1678 | |
|
|
1679 | ////DBG dbg(0,"lat=%f\n",g.lat); |
|
|
1680 | ////DBG dbg(0,"lng=%f\n",g.lng); |
|
|
1681 | ////DBG dbg(0,"str1=%s\n",name); |
|
|
1682 | |
|
|
1683 | struct coord c; |
|
|
1684 | transform_from_geo(projection_mg, &g, &c); |
|
|
1685 | |
|
|
1686 | struct pcoord pc; |
|
|
1687 | pc.x = c.x; |
|
|
1688 | pc.y = c.y; |
|
|
1689 | pc.pro = projection_mg; |
|
|
1690 | |
|
|
1691 | // append new waypoint to navigation |
|
|
1692 | navit_add_waypoint_to_route(global_navit, &pc, name, 1); |
|
|
1693 | } |
|
|
1694 | else if (i == 3) |
|
|
1695 | { |
|
|
1696 | // set destination to lat, lng |
|
|
1697 | |
|
|
1698 | char *name; |
|
|
1699 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1700 | char parse_str[strlen(s) + 1]; |
|
|
1701 | strcpy(parse_str, s); |
|
|
1702 | (*env)->ReleaseStringUTFChars(env, str, s); |
1389 | //dbg(0,"*****string=%s\n",s); |
1703 | ////DBG dbg(0,"*****string=%s\n",s); |
1390 | |
1704 | |
1391 | // set destination to (lat#lon#title) |
1705 | // set destination to (lat#lon#title) |
1392 | struct coord_geo g; |
1706 | struct coord_geo g; |
1393 | char *p; |
1707 | char *p; |
1394 | char *stopstring; |
1708 | char *stopstring; |
1395 | |
1709 | |
1396 | // lat |
1710 | // lat |
1397 | p = strtok (parse_str,"#"); |
1711 | p = strtok(parse_str, "#"); |
1398 | g.lat = strtof(p, &stopstring); |
1712 | g.lat = strtof(p, &stopstring); |
1399 | // lon |
1713 | // lon |
1400 | p = strtok (NULL, "#"); |
1714 | p = strtok(NULL, "#"); |
1401 | g.lng = strtof(p, &stopstring); |
1715 | g.lng = strtof(p, &stopstring); |
1402 | // description |
1716 | // description |
1403 | name = strtok (NULL, "#"); |
1717 | name = strtok(NULL, "#"); |
1404 | |
1718 | |
1405 | //dbg(0,"lat=%f\n",g.lat); |
1719 | ////DBG dbg(0,"lat=%f\n",g.lat); |
1406 | //dbg(0,"lng=%f\n",g.lng); |
1720 | ////DBG dbg(0,"lng=%f\n",g.lng); |
1407 | //dbg(0,"str1=%s\n",name); |
1721 | ////DBG dbg(0,"str1=%s\n",name); |
1408 | |
1722 | |
1409 | struct coord c; |
1723 | struct coord c; |
1410 | transform_from_geo(projection_mg, &g, &c); |
1724 | transform_from_geo(projection_mg, &g, &c); |
1411 | |
1725 | |
1412 | struct pcoord pc; |
1726 | struct pcoord pc; |
1413 | pc.x=c.x; |
1727 | pc.x = c.x; |
1414 | pc.y=c.y; |
1728 | pc.y = c.y; |
1415 | pc.pro=projection_mg; |
1729 | pc.pro = projection_mg; |
1416 | |
1730 | |
1417 | // start navigation asynchronous |
1731 | // start navigation asynchronous |
1418 | navit_set_destination(global_navit, &pc, name, 1); |
1732 | navit_set_destination(global_navit, &pc, name, 1); |
1419 | |
1733 | |
1420 | } |
1734 | } |
1421 | } |
1735 | } |
1422 | } |
|
|
1423 | |
1736 | |
|
|
1737 | //DBG dbg(0,"deleteglobalref\n"); |
|
|
1738 | |
|
|
1739 | (*env)->DeleteGlobalRef(env, str); |
|
|
1740 | str = NULL; |
|
|
1741 | |
|
|
1742 | //DBG dbg(0,"leave\n"); |
|
|
1743 | |
|
|
1744 | } |
|
|
1745 | |
|
|
1746 | void android_send_generic_text(int id, char *text) |
|
|
1747 | { |
|
|
1748 | //DBG dbg(0,"Enter\n"); |
|
|
1749 | |
|
|
1750 | if (NavitGraphicsClass2 == NULL) |
|
|
1751 | { |
|
|
1752 | if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2)) |
|
|
1753 | { |
|
|
1754 | NavitGraphicsClass2 = NULL; |
|
|
1755 | return; |
|
|
1756 | } |
|
|
1757 | } |
|
|
1758 | //DBG dbg(0,"x1\n"); |
|
|
1759 | if (send_generic_text == NULL) |
|
|
1760 | { |
|
|
1761 | android_find_static_method(NavitGraphicsClass2, "send_generic_text", "(ILjava/lang/String;)V", &send_generic_text); |
|
|
1762 | } |
|
|
1763 | //DBG dbg(0,"x2\n"); |
|
|
1764 | if (send_generic_text == NULL) |
|
|
1765 | { |
|
|
1766 | //DBG dbg(0, "no method found\n"); |
|
|
1767 | return; /* exception thrown */ |
|
|
1768 | } |
|
|
1769 | //DBG dbg(0,"x3\n"); |
|
|
1770 | |
|
|
1771 | jstring string1 = (*jnienv)->NewStringUTF(jnienv, text); |
|
|
1772 | (*jnienv)->CallStaticVoidMethod(jnienv, NavitGraphicsClass2, send_generic_text, id, string1); |
|
|
1773 | (*jnienv)->DeleteLocalRef(jnienv, string1); |
|
|
1774 | |
|
|
1775 | //DBG dbg(0,"leave\n"); |
|
|
1776 | } |
|
|
1777 | |