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

Diff of /navit/navit/navit.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 40 Revision 41
186float global_dpi_factor = 1.0f; 186float global_dpi_factor = 1.0f;
187int global_order_level_for_fast_draw = 13; 187int global_order_level_for_fast_draw = 13;
188int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map 188int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map
189 // 1 -> show "normal, english" 189 // 1 -> show "normal, english"
190 // 2 -> show only "english" labels 190 // 2 -> show only "english" labels
191int global_routing_engine = 0; // 0 -> offline ZANavi, 1 -> online OSRM
192float global_overspill_factor = 1.0f; // overspill factor from Java code
191int global_avoid_sharp_turns_flag = 0; // 0 -> normal routing, 1 -> try to avoid sharp turns / u-turns 193int global_avoid_sharp_turns_flag = 0; // 0 -> normal routing, 1 -> try to avoid sharp turns / u-turns
192int global_avoid_sharp_turns_min_angle = 40; // at what angle is it a sharp turn? 194int global_avoid_sharp_turns_min_angle = 40; // at what angle is it a sharp turn?
193int global_avoid_sharp_turns_min_penalty = 2000; // routing penalty for sharp turns 195int global_avoid_sharp_turns_min_penalty = 1000; // routing penalty for sharp turns (DEFAULT = 1000)
194 196
195int global_search_radius_for_housenumbers = 300; // search this far around street-coord to find potential housenumbers for this street 197int global_search_radius_for_housenumbers = 300; // search this far around street-coord to find potential housenumbers for this street
196int global_vehicle_profile = 0; // 0 -> car, 1 -> bicycle, 2 -> bicylce no one-ways 198int global_vehicle_profile = 0; // 0 -> car, 1 -> bicycle, 2 -> bicylce no one-ways
197int global_cycle_lanes_prio = 5; // how much prio weight will be subtracted from prio weight if a road has a cycle lane (painted white line for bicycles) 199int global_cycle_lanes_prio = 5; // how much prio weight will be subtracted from prio weight if a road has a cycle lane (painted white line for bicycles)
198int global_cycle_track_prio = 1; // unused for now!! 200int global_cycle_track_prio = 1; // unused for now!!
199 201
200double global_v_pos_lat = 0.0; // global vehicle position 202double global_v_pos_lat = 0.0; // global vehicle position
201double global_v_pos_lng = 0.0; // global vehicle position 203double global_v_pos_lng = 0.0; // global vehicle position
202double global_v_pos_dir = 0.0; // global vehicle direction 204double global_v_pos_dir = 0.0; // global vehicle direction
203 205
206struct coord global_vehicle_pos_onscreen;
207struct coord_geo global_last_vehicle_pos_geo;
208double ggggg_lat = 0;
209double ggggg_lon = 0;
210
211
204int global_demo_vehicle = 0; 212int global_demo_vehicle = 0;
205int global_demo_vehicle_short_switch = 0; 213int global_demo_vehicle_short_switch = 0;
206long global_last_spoken = -1; 214long global_last_spoken = -1;
207long global_last_spoken_base = 0; 215long global_last_spoken_base = 0;
216float global_road_speed_factor = 0.85f;
217
218float global_level0_announcement = 4.8f;
219float global_level1_announcement = 11.1f;
220float global_level2_announcement = 21.1f;
221float global_levelx_announcement_factor = 6.0f / 4.0f;
222
223float global_b_level0_announcement = 4.8f;
224float global_b_level1_announcement = 11.1f;
225float global_b_level2_announcement = 21.1f;
226float global_b_levelx_announcement_factor = 6.0f / 4.0f;
227
228int global_driven_away_from_route = 0;
229
230int global_enhance_cycleway = 0;
231int global_tracking_show_real_gps_pos = 0;
208 232
209GList *global_all_cbs = NULL; 233GList *global_all_cbs = NULL;
210 234
211struct coord global_debug_route_seg_winner_start; 235struct coord global_debug_route_seg_winner_start;
212struct coord global_debug_route_seg_winner_end; 236struct coord global_debug_route_seg_winner_end;
820 * @param this_ The navit struct 844 * @param this_ The navit struct
821 * @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle 845 * @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle
822 * @param speed The vehicles speed in meters per second 846 * @param speed The vehicles speed in meters per second
823 * @param dir The direction into which the vehicle moves 847 * @param dir The direction into which the vehicle moves
824 */ 848 */
825static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw) 849static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw, int *lold, int *lnew)
826{ 850{
827 struct point pc; 851 struct point pc;
828 int distance, w, h; 852 int w, h;
853 float distance;
829 long new_scale; 854 long new_scale;
830 long scale; 855 long scale;
831 856
832 if (!this_->autozoom_active) 857 if (!this_->autozoom_active)
833 { 858 {
837 if (global_old_vehicle_speed < 1) 862 if (global_old_vehicle_speed < 1)
838 { 863 {
839 return -1; 864 return -1;
840 } 865 }
841 866
867 // --- no autozoom at slow speed ---
842 if (speed < 20) 868 //if (speed < 20)
843 { 869 //{
844 return -1; 870 // return -1;
845 } 871 //}
872 // --- no autozoom at slow speed ---
873
874
846 875
847// this is kaputt!! 876// this is kaputt!!
848#if 0 877#if 0
849 if (global_old_vehicle_speed_for_autozoom > 0) 878 if (global_old_vehicle_speed_for_autozoom > 0)
850 { 879 {
856 } 885 }
857 global_old_vehicle_speed_for_autozoom = speed; 886 global_old_vehicle_speed_for_autozoom = speed;
858#endif 887#endif
859// this is kaputt!! 888// this is kaputt!!
860 889
890
891
861 // distance = speed * this_->autozoom_secs; 892 // distance = speed * this_->autozoom_secs;
862 if (speed > 109) 893 if (speed > 109)
863 { 894 {
864 distance = speed * 10; 895 distance = speed * 10;
865 } 896 }
866 else 897 else
867 { 898 {
868 distance = speed * 5; 899 distance = speed * 5;
869 } 900 }
870 901
902 // if overspill > 1 ?
903 if (global_overspill_factor > 1.0f)
904 {
905 distance = distance * global_overspill_factor;
906 }
907
908
871 // scale = this_->trans->scale * 16; 909 // scale = this_->trans->scale * 16;
872 scale = transform_get_scale(this_->trans); 910 scale = transform_get_scale(this_->trans);
873 911
874 transform_get_size(this_->trans, &w, &h); 912 transform_get_size(this_->trans, &w, &h);
875 transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL); 913 transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL);
876 914
877 //dbg(0,"autozoom: dist=%d\n", distance); 915 // dbg(0,"autozoom: dist=%d\n", distance);
878 //dbg(0,"autozoom: scale=%d\n", (int)scale); 916 // dbg(0,"autozoom: scale=%d\n", (int)scale);
879 //dbg(0,"autozoom:o speed=%d\n", speed); 917 // dbg(0,"autozoom:o speed=%d\n", speed);
880 //dbg(0,"autozoom:n speed=%d\n", global_old_vehicle_speed); 918 // dbg(0,"autozoom:n speed=%d\n", global_old_vehicle_speed);
881 919
882 /* We make sure that the point we want to see is within a certain range 920 /* We make sure that the point we want to see is within a certain range
883 * around the vehicle. The radius of this circle is the size of the 921 * around the vehicle. The radius of this circle is the size of the
884 * screen. This doesn't necessarily mean the point is visible because of 922 * screen. This doesn't necessarily mean the point is visible because of
885 * perspective etc. Quite rough, but should be enough. */ 923 * perspective etc. Quite rough, but should be enough. */
886 924
887 if (w > h) 925 if (w > h)
888 { 926 {
889 new_scale = (long)( ((float)distance / (float)h) * 16); 927 new_scale = (long)( (distance / (float)h) * 16);
890 } 928 }
891 else 929 else
892 { 930 {
893 new_scale = (long)( ((float)distance / (float)w) * 16); 931 new_scale = (long)( (distance / (float)w) * 16);
894 } 932 }
895 933
896 if (new_scale < this_->autozoom_min) 934 if (new_scale < this_->autozoom_min)
897 { 935 {
898 new_scale = this_->autozoom_min; 936 new_scale = this_->autozoom_min;
899 } 937 }
900 938
901 //dbg(0,"autozoom:w scale=%d\n", (int)new_scale); 939 // dbg(0,"autozoom:w n.scale=%d o.scale=%d\n", (int)new_scale, (int)scale);
902 940
903 //if (abs(new_scale - scale) < 2) 941 //if (abs(new_scale - scale) < 2)
904 //{ 942 //{
905 // return; // Smoothing 943 // return; // Smoothing
906 //} 944 //}
916 { 954 {
917 scale = scale + 4; 955 scale = scale + 4;
918 } 956 }
919 else 957 else
920 { 958 {
921 scale = scale++; 959 scale = scale + 1;
922 } 960 }
923 } 961 }
924 else if (new_scale < scale) 962 else if (new_scale < scale)
925 { 963 {
926 // zoom in 964 // zoom in
927 if ((new_scale + 5500) < scale) 965 if ((new_scale + 220500) < scale) // lower threshold
928 { 966 {
929 scale = scale - 4000; 967 scale = (int)((float)scale * 0.85f);
968 // dbg(0,"autozoom:step 8\n");
930 } 969 }
970 else if ((new_scale + 130500) < scale) // lower threshold
971 {
972 scale = (int)((float)scale * 0.85f);
973 // dbg(0,"autozoom:step 7\n");
974 }
975 else if ((new_scale + 4000) < scale) // lower threshold
976 {
977 scale = (int)((float)scale * 0.85f);
978 // dbg(0,"autozoom:step 6\n");
979 }
931 else if ((new_scale + 1850) < scale) 980 else if ((new_scale + 1850) < scale) // lower threshold
932 { 981 {
933 scale = scale - 1000; 982 // scale = scale - 1000;
983 scale = (int)((float)scale * 0.85f);
984 // dbg(0,"autozoom:step 5\n");
934 } 985 }
935 else if ((new_scale + 450) < scale) 986 else if ((new_scale + 90) < scale) // lower threshold
936 { 987 {
988 // scale = scale - 200;
989 scale = (int)((float)scale * 0.85f);
990 // dbg(0,"autozoom:step 4\n");
991 }
992 else if ((new_scale + 25) < scale) // lower threshold
993 {
994 scale = scale - 8;
995 // dbg(0,"autozoom:step 3\n");
996 }
997 else if ((new_scale + 7) < scale) // lower threshold
998 {
937 scale = scale - 200; 999 scale = scale - 2;
938 } 1000 // dbg(0,"autozoom:step 2\n");
939 else if ((new_scale + 20) < scale)
940 {
941 scale = scale - 10;
942 }
943 else if ((new_scale + 5) < scale)
944 {
945 scale = scale - 4;
946 } 1001 }
947 else 1002 else
948 { 1003 {
949 scale = scale--; 1004 scale = scale - 1;
1005 // dbg(0,"autozoom:step 1\n");
950 } 1006 }
951 } 1007 }
952 else 1008 else
953 { 1009 {
954 // no change 1010 // no change
955 return -1; 1011 return -1;
956 } 1012 }
957 1013
958 //dbg(0,"autozoom:n scale=%d\n", (int)scale); 1014 // dbg(0,"autozoom:n scale=%d\n", (int)scale);
1015
1016 // OLD zoom is applied here -------------------------
1017 struct coord c_left;
1018 struct point p_left;
1019 p_left.x = 0;
1020 p_left.y = 200;
1021 transform_reverse(this_->trans, &p_left, &c_left);
1022 struct coord c_right;
1023 struct point p_right;
1024 p_right.x = 200;
1025 p_right.y = 200;
1026 transform_reverse(this_->trans, &p_right, &c_right);
1027 // OLD zoom is applied here -------------------------
1028
959 1029
960 if (scale >= this_->autozoom_min) 1030 if (scale >= this_->autozoom_min)
961 { 1031 {
962 navit_scale(this_, (long) scale, &pc, 0); 1032 navit_scale(this_, (long) scale, &pc, 0);
963 } 1033 }
966 //if (scale != this_->autozoom_min) 1036 //if (scale != this_->autozoom_min)
967 //{ 1037 //{
968 navit_scale(this_, this_->autozoom_min, &pc, 0); 1038 navit_scale(this_, this_->autozoom_min, &pc, 0);
969 //} 1039 //}
970 } 1040 }
1041
1042 // new zoom is applied here already -----------------
1043 struct point p_new_left;
1044 transform(global_navit->trans, transform_get_projection(this_->trans), &c_left, &p_new_left, 1, 0, 0, NULL);
1045 struct point p_new_right;
1046 transform(global_navit->trans, transform_get_projection(this_->trans), &c_right, &p_new_right, 1, 0, 0, NULL);
1047
1048 *lold = 200;
1049 *lnew = abs(p_new_right.x - p_new_left.x);
1050 // new zoom is applied here already -----------------
1051
971 1052
972 // return new scale value 1053 // return new scale value
973 return scale; 1054 return scale;
974} 1055}
975 1056
1023 else 1104 else
1024 { 1105 {
1025 navit_zoom_in(this_, factor, NULL); 1106 navit_zoom_in(this_, factor, NULL);
1026 } 1107 }
1027} 1108}
1109
1110void navit_zoom_to_scale_no_draw(struct navit *this_, int new_scale)
1111{
1112 long scale = transform_get_scale(this_->trans);
1113 long new_scale_long = new_scale;
1114
1115 // only do something if scale changed!
1116 if (scale != new_scale_long)
1117 {
1118 navit_scale(this_, new_scale_long, NULL, 0);
1119 }
1120}
1121
1028 1122
1029void navit_zoom_to_scale(struct navit *this_, int new_scale) 1123void navit_zoom_to_scale(struct navit *this_, int new_scale)
1030{ 1124{
1031 long scale = transform_get_scale(this_->trans); 1125 long scale = transform_get_scale(this_->trans);
1032 long new_scale_long = new_scale; 1126 long new_scale_long = new_scale;
1180 } 1274 }
1181 } 1275 }
1182} 1276}
1183 1277
1184 1278
1279void navit_enhance_cycleway(struct navit *this)
1280{
1281 GList *itms;
1282 struct itemgra *itm;
1283 struct element *e;
1284 GList *es, *types;
1285 int found = 0;
1286 GList* layers = this->layout_current->layers;
1287
1288 global_enhance_cycleway = 1;
1289
1290 while (layers)
1291 {
1292
1293 struct layer*l = layers->data;
1294 if (l)
1295 {
1296
1297 itms = l->itemgras;
1298 while (itms)
1299 {
1300 itm = itms->data;
1301 found = 0;
1302
1303 types = itm->type;
1304 while (types)
1305 {
1306 if (GPOINTER_TO_INT(types->data) == type_cycleway)
1307 {
1308 found = 1;
1309 }
1310 types = g_list_next(types);
1311 }
1312
1313 if (found == 1)
1314 {
1315
1316 dbg(0, "CYC:001:min=%d max=%d\n", itm->order.min, itm->order.max);
1317
1318 if (itm->order.min == 14)
1319 {
1320 itm->order.min = 10;
1321 }
1322
1323 es = itm->elements;
1324 while (es)
1325 {
1326 e = es->data;
1327
1328 if (e->type == element_polyline)
1329 {
1330 e->u.polyline.width = e->u.polyline.width * 2;
1331 }
1332
1333 es = g_list_next(es);
1334 }
1335 }
1336
1337 itms = g_list_next(itms);
1338 }
1339
1340 }
1341 layers = g_list_next(layers);
1342
1343 }
1344
1345}
1346
1347
1348void navit_reset_cycleway(struct navit *this)
1349{
1350 GList *itms;
1351 struct itemgra *itm;
1352 struct element *e;
1353 GList *es, *types;
1354 int found = 0;
1355 GList* layers = this->layout_current->layers;
1356
1357 global_enhance_cycleway = 0;
1358
1359 while (layers)
1360 {
1361
1362 struct layer*l = layers->data;
1363 if (l)
1364 {
1365
1366 itms = l->itemgras;
1367 while (itms)
1368 {
1369 itm = itms->data;
1370 found = 0;
1371
1372 types = itm->type;
1373 while (types)
1374 {
1375 if (GPOINTER_TO_INT(types->data) == type_cycleway)
1376 {
1377 found = 1;
1378 }
1379 types = g_list_next(types);
1380 }
1381
1382 if (found == 1)
1383 {
1384 if (itm->order.min == 10)
1385 {
1386 itm->order.min = 14;
1387 }
1388
1389 es = itm->elements;
1390 while (es)
1391 {
1392 e = es->data;
1393
1394 if (e->type == element_polyline)
1395 {
1396 e->u.polyline.width = e->u.polyline.width / 2;
1397 }
1398
1399 es = g_list_next(es);
1400 }
1401 }
1402
1403 itms = g_list_next(itms);
1404 }
1405
1406 }
1407 layers = g_list_next(layers);
1408
1409 }
1410
1411}
1412
1413
1185void navit_layer_toggle_active(struct navit *this, char *name, int draw) 1414void navit_layer_toggle_active(struct navit *this, char *name, int draw)
1186{ 1415{
1187 if (name) 1416 if (name)
1188 { 1417 {
1189 if (this->layout_current && this->layout_current->layers) 1418 if (this->layout_current && this->layout_current->layers)
1794 2023
1795 // changed default to 1 2024 // changed default to 1
1796 this_->center_timeout = 1; 2025 this_->center_timeout = 1;
1797 this_->use_mousewheel = 1; 2026 this_->use_mousewheel = 1;
1798 this_->autozoom_secs = 10; 2027 this_->autozoom_secs = 10;
1799 this_->autozoom_min = 6; 2028 this_->autozoom_min = 5;
1800 this_->autozoom_active = 0; 2029 this_->autozoom_active = 0;
1801 this_->zoom_min = 1; 2030 this_->zoom_min = 1;
1802 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3; 2031 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3;
1803 this_->follow_cursor = 1; 2032 this_->follow_cursor = 1;
1804 this_->radius = 30; 2033 this_->radius = 30;
2309 attr.u.num = 1; 2538 attr.u.num = 1;
2310 } 2539 }
2311 2540
2312 // dbg(1, "this_.speech->active %i\n", attr.u.num); 2541 // dbg(1, "this_.speech->active %i\n", attr.u.num);
2313 2542
2543 dbg(0, "NAV_TURNAROUND:008:enter\n");
2544
2314 if (!attr.u.num) 2545 if (!attr.u.num)
2315 { 2546 {
2316 return; 2547 return;
2317 } 2548 }
2318 2549
2323 mr = map_rect_new(map, NULL); 2554 mr = map_rect_new(map, NULL);
2324 2555
2325 if (mr) 2556 if (mr)
2326 { 2557 {
2327 while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none)) 2558 while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none))
2328 ; 2559 {
2560 dbg(0, "NAV_TURNAROUND:008a:%s\n", item_to_name(item->type));
2561 }
2329 2562
2330 if (item && item_attr_get(item, attr_navigation_speech, &attr)) 2563 dbg(0, "NAV_TURNAROUND:008b:item=%p\n", item);
2564
2565 if (item && item_attr_get(item, attr_navigation_speech, &attr)) // this calls --> navigation_map_item_attr_get(...) --> show_next_maneuvers(...)
2331 { 2566 {
2332 //dbg(0,"say(2) s=X%sX\n", attr.u.str); 2567 //dbg(0,"say(2) s=X%sX\n", attr.u.str);
2568
2569 dbg(0, "NAV_TURNAROUND:009:%s\n", attr.u.str);
2570
2333 if (strlen(attr.u.str) > 0) 2571 if (strlen(attr.u.str) > 0)
2334 { 2572 {
2335 speech_say(this_->speech, attr.u.str); 2573 speech_say(this_->speech, attr.u.str);
2336 } 2574 }
2337 //navit_add_message(this_, attr.u.str); 2575 //navit_add_message(this_, attr.u.str);
3559 if (orientation != -1) 3797 if (orientation != -1)
3560 { 3798 {
3561 transform_set_yaw(this_->trans, orientation); 3799 transform_set_yaw(this_->trans, orientation);
3562 } 3800 }
3563 3801
3802 // if overspill > 1 ?
3803 if (global_overspill_factor > 1.0f)
3804 {
3805 coord_rect_extend_by_percent(&r, (global_overspill_factor - 1.0f));
3806 }
3807
3564 navit_zoom_to_rect(this_, &r); 3808 navit_zoom_to_rect(this_, &r);
3565} 3809}
3566 3810
3567static void navit_cmd_zoom_to_route(struct navit *this) 3811static void navit_cmd_zoom_to_route(struct navit *this)
3568{ 3812{
3607 } 3851 }
3608 3852
3609 if (this_->ready == 3) 3853 if (this_->ready == 3)
3610 { 3854 {
3611 navit_draw(this_); 3855 navit_draw(this_);
3856 }
3857}
3858
3859
3860void navit_set_center_no_draw(struct navit *this_, struct pcoord *center, int set_timeout)
3861{
3862
3863
3864 ////DBG dbg(0,"EEnter\n");
3865 struct coord *c = transform_center(this_->trans);
3866 struct coord c1, c2;
3867 enum projection pro = transform_get_projection(this_->trans);
3868
3869 if (pro != center->pro)
3870 {
3871 c1.x = center->x;
3872 c1.y = center->y;
3873 transform_from_to(&c1, center->pro, &c2, pro);
3874 }
3875 else
3876 {
3877 c2.x = center->x;
3878 c2.y = center->y;
3879 }
3880
3881 *c = c2;
3882 if (set_timeout)
3883 {
3884 navit_set_timeout(this_);
3612 } 3885 }
3613} 3886}
3614 3887
3615static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) 3888static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout)
3616{ 3889{
3696 return; 3969 return;
3697} 3970}
3698 3971
3699static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) 3972static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir)
3700{ 3973{
3701
3702
3703 ////DBG dbg(0,"EEnter\n"); 3974 //// dbg(0,"EEnter\n");
3975
3704 int width, height; 3976 int width, height;
3705 struct navit_vehicle *nv = this_->vehicle; 3977 struct navit_vehicle *nv = this_->vehicle;
3706 3978
3979 // valid values: 0 - 50 (0 -> center of screen, 50 -> bottom of screen)
3707 float offset = this_->radius; // Cursor offset from the center of the screen (percent). 3980 // float offset = this_->radius; // Cursor offset from the center of the screen (percent). // percent of what??
3981
3982 float offset = 0;
3983
3984
3985#if 0
3986
3708#if 0 /* Better improve track.c to get that issue resolved or make it configurable with being off the default, the jumping back to the center is a bit annoying */ 3987/* Better improve track.c to get that issue resolved or make it configurable with being off the default, the jumping back to the center is a bit annoying */
3709 float min_offset = 0.; // Percent offset at min_offset_speed. 3988 float min_offset = 0.; // Percent offset at min_offset_speed.
3710 float max_offset = 30.; // Percent offset at max_offset_speed. 3989 float max_offset = 30.; // Percent offset at max_offset_speed.
3711 int min_offset_speed = 2; // Speed in km/h 3990 int min_offset_speed = 2; // Speed in km/h
3712 int max_offset_speed = 50; // Speed ini km/h 3991 int max_offset_speed = 50; // Speed ini km/h
3713 // Calculate cursor offset from the center of the screen, upon speed. 3992 // Calculate cursor offset from the center of the screen, upon speed.
3721 } 4000 }
3722 else 4001 else
3723 { 4002 {
3724 offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed); 4003 offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed);
3725 } 4004 }
4005
3726#endif 4006#endif
3727 4007
3728 transform_get_size(this_->trans, &width, &height); 4008 transform_get_size(this_->trans, &width, &height);
4009
4010 if (height == 0)
4011 {
4012 offset = 0;
4013 }
4014 else
4015 {
4016 // dbg(0, "VEHICLE_OFFSET:a:r=%d %d %d\n", (int)this_->radius, (int)(height - this_->radius), (int)((height - this_->radius) - (height / 2)));
4017 offset = (float)((height - this_->radius) - (height / 2)) / (float)height * (float)50.0;
4018 // dbg(0, "VEHICLE_OFFSET:b:o=%d\n", (int)offset);
4019 }
4020
4021
4022 // dbg(0, "VEHICLE_OFFSET:or=%d keep_or=%d\n", this_->orientation, keep_orientation);
4023
3729 if (this_->orientation == -1 || keep_orientation) 4024 if (this_->orientation == -1 || keep_orientation)
3730 { 4025 {
3731 p->x = 50 * width / 100; 4026 p->x = 50 * width / 100; // = (width / 2) // why doesnt it just say that?
3732 p->y = (50 + offset) * height / 100; 4027 p->y = (50 + (int)offset) * height / 100;
4028
4029 // dbg(0, "VEHICLE_OFFSET:2:%d %d %d\n", p->y, width, height);
4030
3733 if (dir) 4031 if (dir)
3734 { 4032 {
3735 *dir = keep_orientation ? this_->orientation : nv->dir; 4033 *dir = keep_orientation ? this_->orientation : nv->dir;
3736 } 4034 }
3737 } 4035 }
3739 { 4037 {
3740 int mdir; 4038 int mdir;
3741 if (this_->tracking && this_->tracking_flag) 4039 if (this_->tracking && this_->tracking_flag)
3742 { 4040 {
3743 mdir = tracking_get_angle(this_->tracking) - this_->orientation; 4041 mdir = tracking_get_angle(this_->tracking) - this_->orientation;
3744 dbg(0, "+++++tr angle=%d\n", tracking_get_angle(this_->tracking)); 4042 // dbg(0, "+++++tr angle=%d\n", tracking_get_angle(this_->tracking));
3745 dbg(0, "+++++this ori=%d\n", this_->orientation); 4043 // dbg(0, "+++++this ori=%d\n", this_->orientation);
3746 } 4044 }
3747 else 4045 else
3748 { 4046 {
3749 mdir = nv->dir - this_->orientation; 4047 mdir = nv->dir - this_->orientation;
3750 } 4048 }
3751 4049
3752 p->x = (50 - offset * sin(M_PI * mdir / 180.)) * width / 100; 4050 p->x = (50 - offset * sin(M_PI * mdir / 180.)) * width / 100;
3753 p->y = (50 + offset * cos(M_PI * mdir / 180.)) * height / 100; 4051 p->y = (50 + offset * cos(M_PI * mdir / 180.)) * height / 100;
4052
4053 // dbg(0, "VEHICLE_OFFSET:3:%d %d %d\n", p->y, width, height);
4054
3754 if (dir) 4055 if (dir)
3755 { 4056 {
3756 *dir = this_->orientation; 4057 *dir = this_->orientation;
3757 } 4058 }
3758 } 4059 }
3768 struct point pn; 4069 struct point pn;
3769 struct navit_vehicle *nv = this_->vehicle; 4070 struct navit_vehicle *nv = this_->vehicle;
3770 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); 4071 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
3771 transform_set_yaw(this_->trans, dir); 4072 transform_set_yaw(this_->trans, dir);
3772 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); 4073 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
3773 // OLD // navit_autozoom(this_, &nv->coord, nv->speed, 0); 4074 // OLD // navit_aXXutozoom(this_, &nv->coord, nv->speed, 0);
3774} 4075}
3775 4076
3776static void navit_set_center_cursor_draw(struct navit *this_) 4077static void navit_set_center_cursor_draw(struct navit *this_)
3777{ 4078{
3778 4079
4775 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *); 5076 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
4776 void *attr_object; 5077 void *attr_object;
4777 char *destination_file; 5078 char *destination_file;
4778 long new_scale_value; 5079 long new_scale_value;
4779 long old_scale_value; 5080 long old_scale_value;
5081 int l_old;
5082 int l_new;
4780 5083
4781 if (this_->ready != 3) 5084 if (this_->ready != 3)
4782 { 5085 {
4783 //profile(0,"return 1\n"); 5086 //profile(0,"return 1\n");
4784#ifdef NAVIT_ROUTING_DEBUG_PRINT 5087#ifdef NAVIT_ROUTING_DEBUG_PRINT
4945 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord); 5248 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
4946 5249
4947 // save this position 5250 // save this position
4948 global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat; 5251 global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat;
4949 global_last_vehicle_pos_geo.lng = attr_pos.u.coord_geo->lng; 5252 global_last_vehicle_pos_geo.lng = attr_pos.u.coord_geo->lng;
5253
5254 ggggg_lat = attr_pos.u.coord_geo->lat;
5255 ggggg_lon = attr_pos.u.coord_geo->lng;
5256 // dbg(0, "PPPOS:%f %f lll=%f", global_last_vehicle_pos_geo.lat, global_last_vehicle_pos_geo.lng, ggggg_lat);
5257
4950 // save this position 5258 // save this position
4951 5259
4952 5260
4953 // XXX // dbg(0,"v1 lat:%f lon:%f x:%d y:%d\n",attr_pos.u.coord_geo->lat, attr_pos.u.coord_geo->lng, nv->coord.x, nv->coord.y); 5261 // XXX // dbg(0,"v1 lat:%f lon:%f x:%d y:%d\n",attr_pos.u.coord_geo->lat, attr_pos.u.coord_geo->lng, nv->coord.x, nv->coord.y);
4954 5262
5008 5316
5009 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 5317 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
5010 // XXX // dbg(0,"v2 px:%d py:%d x:%d y:%d\n", cursor_pnt.x, cursor_pnt.y, nv->coord.x, nv->coord.y); 5318 // XXX // dbg(0,"v2 px:%d py:%d x:%d y:%d\n", cursor_pnt.x, cursor_pnt.y, nv->coord.x, nv->coord.y);
5011 5319
5012 // ------- AUTOZOOM --------- 5320 // ------- AUTOZOOM ---------
5321 l_old = 0;
5322 l_new = 0;
5013 new_scale_value = navit_autozoom(this_, &nv->coord, nv->speed, 0); 5323 new_scale_value = navit_autozoom(this_, &nv->coord, nv->speed, 0, &l_old, &l_new);
5324 // dbg(0, "l_old=%d l_new=%d\n", l_old, l_new);
5014 // ------- AUTOZOOM --------- 5325 // ------- AUTOZOOM ---------
5015 5326
5016 if (old_pos_invalid == 0) 5327 if (old_pos_invalid == 0)
5017 { 5328 {
5018 int delta_x = cursor_pnt.x - old_cursor_pnt.x; 5329 int delta_x = cursor_pnt.x - old_cursor_pnt.x;
5025 delta_zoom = (int)(new_scale_value - old_scale_value); 5336 delta_zoom = (int)(new_scale_value - old_scale_value);
5026 } 5337 }
5027 5338
5028#ifdef HAVE_API_ANDROID 5339#ifdef HAVE_API_ANDROID
5029 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle); 5340 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle);
5030 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom); 5341 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom, l_old, l_new);
5031#endif 5342#endif
5032 } 5343 }
5033 5344
5034 5345
5035 5346
5074 5385
5075 5386
5076 5387
5077 // where does this go????? ---------- 5388 // where does this go????? ----------
5078 // where does this go????? ---------- 5389 // where does this go????? ----------
5390 //
5391 // i think this updates the OSD GUIs
5392 //
5079 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle); 5393 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle);
5080 // where does this go????? ---------- 5394 // where does this go????? ----------
5081 // where does this go????? ---------- 5395 // where does this go????? ----------
5082 5396
5083 5397
5098 // waypoint reached 5412 // waypoint reached
5099 android_return_generic_int(5, 1); 5413 android_return_generic_int(5, 1);
5100#ifdef NAVIT_SAY_DEBUG_PRINT 5414#ifdef NAVIT_SAY_DEBUG_PRINT
5101 android_send_generic_text(1,"+*#O:Waypoint reached\n"); 5415 android_send_generic_text(1,"+*#O:Waypoint reached\n");
5102#endif 5416#endif
5417 if (global_routing_engine != 1) // not OSRM routing
5418 {
5103 // say it 5419 // say it
5104 navit_say(this_, _("Waypoint reached")); 5420 navit_say(this_, _("Waypoint reached"));
5421 }
5105#endif 5422#endif
5106 break; 5423 break;
5107 case 2: 5424 case 2:
5108 navit_set_destination(this_, NULL, NULL, 0); 5425 navit_set_destination(this_, NULL, NULL, 0);
5109 // ** inform java that we reached our destination ** 5426 // ** inform java that we reached our destination **
5680 else if ((type >= type_line) && (type <= type_ferry)) 5997 else if ((type >= type_line) && (type <= type_ferry))
5681 { 5998 {
5682 return 1; 5999 return 1;
5683 } 6000 }
5684 else if (type == type_street_unkn) 6001 else if (type == type_street_unkn)
6002 {
6003 return 1;
6004 }
6005 else if (type == type_street_service)
6006 {
6007 return 1;
6008 }
6009 else if (type == type_street_pedestrian)
6010 {
6011 return 1;
6012 }
6013 else if (type == type_street_parking_lane)
6014 {
6015 return 1;
6016 }
6017 else if (type == type_ramp_highway_land)
6018 {
6019 return 1;
6020 }
6021 else if (type == type_ramp_street_4_city)
6022 {
6023 return 1;
6024 }
6025 else if (type == type_ramp_street_3_city)
6026 {
6027 return 1;
6028 }
6029 else if (type == type_ramp_street_2_city)
5685 { 6030 {
5686 return 1; 6031 return 1;
5687 } 6032 }
5688 else if ((type >= type_aeroway_runway) && (type <= type_footway_and_piste_nordic)) 6033 else if ((type >= type_aeroway_runway) && (type <= type_footway_and_piste_nordic))
5689 { 6034 {
5906 sd = street_get_data(item); 6251 sd = street_get_data(item);
5907 if (!sd) 6252 if (!sd)
5908 { 6253 {
5909 continue; 6254 continue;
5910 } 6255 }
6256
5911 //dbg(0,"6 sd x:%d sd y:%d count:%d\n", sd->c->x, sd->c->y, sd->count); 6257 //dbg(0,"6 sd x:%d sd y:%d count:%d\n", sd->c->x, sd->c->y, sd->count);
5912 //dbg(0,"6 c x:%d c y:%d\n", c.x, c.y); 6258 //dbg(0,"6 c x:%d c y:%d\n", c.x, c.y);
5913 dist = transform_distance_polyline_sq__v2(sd->c, sd->count, &c); 6259 dist = transform_distance_polyline_sq__v2(sd->c, sd->count, &c);
5914 //dbg(0,"mindist:%d dist:%d\n", mindist, dist); 6260 //dbg(0,"mindist:%d dist:%d\n", mindist, dist);
5915 if (dist < mindist) 6261 if (dist < mindist)
6459 6805
6460 fprintf(fp,"%s",trailer1); 6806 fprintf(fp,"%s",trailer1);
6461 fclose(fp); 6807 fclose(fp);
6462} 6808}
6463 6809
6810GList* navit_route_export_to_java_string(struct navit *this_, int result_id)
6811{
6812 struct point p;
6813 struct map *map=NULL;
6814 struct navigation *nav = NULL;
6815 struct map_rect *mr=NULL;
6816 struct item *item =NULL;
6817 struct attr attr,route;
6818 struct coord c;
6819 // struct coord c_end;
6820 struct coord_geo g;
6821 struct transformation *trans;
6822 char *d = NULL;
6823 char *result_string = NULL;
6824 GList* result = NULL;
6825
6826 nav = navit_get_navigation(this_);
6827
6828 if (!nav)
6829 {
6830 return NULL;
6831 }
6832
6833 map = navigation_get_map(nav);
6834
6835 if (map)
6836 {
6837 mr = map_rect_new(map,NULL);
6838 }
6839 else
6840 {
6841 return;
6842 }
6843
6844 trans = navit_get_trans(this_);
6845
6846 mr = map_rect_new(map,NULL);
6847 while ((item = map_rect_get_item(mr)))
6848 {
6849
6850 // dbg(0, "005 ============== = %s : %d\n", item_to_name(item->type), item->id_lo);
6851
6852 //if (item_attr_get(item, attr_navigation_short, &attr))
6853 //{
6854 // dbg(0, "005.c.01:%s\n", attr.u.str);
6855 //}
6856
6857 if (item_attr_get(item, attr_length, &attr))
6858 {
6859 if (attr.u.num > 0)
6860 {
6861 d = get_distance(nav, attr.u.num, attr_navigation_short, 1);
6862 }
6863
6864 // dbg(0, "005.c.02:%d %s\n", attr.u.num, d); // dist to next turn in meters! (take care when in imperial mode!)
6865 }
6866 else
6867 {
6868 d = NULL;
6869 }
6870
6871 if ((item_attr_get(item, attr_navigation_long_exact, &attr)) || (item->type == type_nav_waypoint))
6872 {
6873 dbg(0, "NAVICG:call type=%s\n", item_to_name(item->type));
6874 item_coord_get(item, &c, 1);
6875 dbg(0, "NAVICG:call END\n");
6876
6877 //int num_coords = 0;
6878 //while (item_coord_get(item, &c_end, 1))
6879 //{
6880 // num_coords++;
6881 //}
6882
6883 transform_to_geo(projection_mg, &c, &g);
6884
6885 if (result)
6886 {
6887 }
6888 else
6889 {
6890 result = g_list_append(result, g_strdup_printf("%d", result_id));
6891 }
6892
6893 dbg(0, "013 %s %s\n", item_to_name(item->type), map_convert_string(item->map, attr.u.str));
6894
6895 if (item->type == type_nav_waypoint)
6896 {
6897 result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:%s:%s", d ? d : "", g.lat, g.lng, item_to_name(item->type), _("Waypoint")));
6898 }
6899 else
6900 {
6901 result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:%s:%s", d ? d : "", g.lat, g.lng, item_to_name(item->type), map_convert_string(item->map,attr.u.str)));
6902 }
6903 }
6904 else
6905 {
6906 // must be the start point (without navigation command)
6907 item_coord_get(item, &c, 1);
6908 transform_to_geo(projection_mg, &c, &g);
6909
6910 if (result)
6911 {
6912 }
6913 else
6914 {
6915 result = g_list_append(result, g_strdup_printf("%d", result_id));
6916 }
6917
6918 // dbg(0, "019.0 %p\n", attr.u.str);
6919 // dbg(0, "019.b %d\n", item->type);
6920 // dbg(0, "019.c %s\n", item_to_name(item->type));
6921 result = g_list_append(result, g_strdup_printf("%s:%4.8f:%4.8f:+start+:", d ? d : "", g.lat, g.lng));
6922 }
6923
6924 if (d)
6925 {
6926 g_free(d);
6927 d = NULL;
6928 }
6929
6930 }
6931
6932 map_rect_destroy(mr);
6933
6934 return result;
6935
6936}
6937
6464void navit_route_export_gpx_to_file(struct navit *this_, char *filename) 6938void navit_route_export_gpx_to_file(struct navit *this_, char *filename)
6465{ 6939{
6466 6940
6467 6941
6468 6942

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

   
Visit the ZANavi Wiki