diff options
author | lains <lains@caramail.com> | 2019-09-22 17:33:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-22 17:33:56 +0200 |
commit | bb680f70f18f1200bdc25b45031e26ac07c71979 (patch) | |
tree | ade0e3a07b26f4aae2f4e64be5fe35afc828fe6b /navit/android.c | |
parent | deccb6c4379e135ae45513a7bfef3b4998f24e94 (diff) | |
download | navit-bb680f70f18f1200bdc25b45031e26ac07c71979.tar.gz |
Add/Android: Provide geo coordinates for clicked position in contextual menu (#794)
* Adding unescape string utility and unescaping alls values in textfile attributes
* Moving coordinates_geo out of internal use in gui_internal_command.c (to coord.c)
* Moving gui_internal_escape() into generic str_escape() function in util.c
* Moving strncpy_unescape() into generic function in util.c
* Using geo coords as item name in Android contextual menu "Route Here"
* Using string escaping (for double quotes) when writing former destinations to file
* Adding new type DEGREES_MINUTES_SECONDS_BRIEF to factorize coordinates_geo()
And fixing the example strings to match what is actually output by the function
* Adding support for DEGREES_MINUTES_SECONDS_BRIEF format into coord_format
And add internal coord_format_with_sep() to specify the separator
* Fixing doxygen doc for coord_format_with_sep()
* Making coord_format() inline
* Using new factorized generic function coord_geo_format_short() instead of coordinates_geo()
* Changing single contextual window title with GPS coords on Android
* Adding string bytes length for each coord to string format, using short format in pcoord_format_short() and coord_geo_format_short()
* Using pcoord_format_short() in android
Diffstat (limited to 'navit/android.c')
-rw-r--r-- | navit/android.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/navit/android.c b/navit/android.c index dc506ffb0..4c6d1ff1e 100644 --- a/navit/android.c +++ b/navit/android.c @@ -11,6 +11,7 @@ #include "callback.h" #include "country.h" #include "projection.h" +#include "coord.h" #include "map.h" #include "mapset.h" #include "navit_nls.h" @@ -141,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_KeypressCallbac const char *s; dbg(lvl_debug,"enter %p %p",(struct callback *)id,str); s=(*env)->GetStringUTFChars(env, str, NULL); - dbg(lvl_debug,"key=%d",s); + dbg(lvl_debug,"key=%s",s); if (id) callback_call_1((struct callback *)id,s); (*env)->ReleaseStringUTFChars(env, str, s); @@ -190,8 +191,6 @@ JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitTraff_onFeedReceived(JNI (*env)->ReleaseStringUTFChars(env, feed, s); } - - // type: 0=town, 1=street, 2=House# void android_return_search_result(struct jni_object *jni_o, int type, struct pcoord *location, const char *address) { struct coord_geo geo_location; @@ -329,16 +328,17 @@ JNIEXPORT jint JNICALL Java_org_navitproject_navit_NavitGraphics_CallbackMessage transform_reverse(transform, &p, &c); - pc.x = c.x; pc.y = c.y; pc.pro = transform_get_projection(transform); - dbg(lvl_debug,"22x=%d",pc.x); - dbg(lvl_debug,"22y=%d",pc.y); + char coord_str[32]; + pcoord_format_short(&pc, coord_str, sizeof(coord_str), " "); + + dbg(lvl_debug,"Setting destination to %s",coord_str); // start navigation asynchronous - navit_set_destination(attr.u.navit, &pc, parse_str, 1); + navit_set_destination(attr.u.navit, &pc, coord_str, 1); } break; case 3: { @@ -388,6 +388,36 @@ JNIEXPORT jint JNICALL Java_org_navitproject_navit_NavitGraphics_CallbackMessage return ret; } +JNIEXPORT jstring JNICALL Java_org_navitproject_navit_NavitGraphics_getCoordForPoint( JNIEnv* env, jobject thiz, + jint id, int x, int y) { + + jstring return_string = NULL; + + struct attr attr; + config_get_attr(config_get(), attr_navit, &attr, NULL); + + struct transformation *transform=navit_get_trans(attr.u.navit); + struct point p; + struct coord c; + struct pcoord pc; + + p.x = x; + p.y = y; + + transform_reverse(transform, &p, &c); + + pc.x = c.x; + pc.y = c.y; + pc.pro = transform_get_projection(transform); + + char coord_str[32]; + pcoord_format_short(&pc, coord_str, sizeof(coord_str), " "); + + dbg(lvl_debug,"Display point x=%d y=%d is \"%s\"",x,y,coord_str); + return_string = (*env)->NewStringUTF(env,coord_str); + return return_string; +} + JNIEXPORT jstring JNICALL Java_org_navitproject_navit_NavitGraphics_GetDefaultCountry( JNIEnv* env, jobject thiz, int channel, jobject str) { struct attr search_attr, country_name, country_iso2, *country_attr; |