/[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 33 Revision 34
1/** 1/**
2 * ZANavi, Zoff Android Navigation system. 2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc> 3 * Copyright (C) 2011-2013 Zoff <zoff@zoff.cc>
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
125int routing_mode = 0; 125int routing_mode = 0;
126int MYSTERY_SPEED = 2; 126int MYSTERY_SPEED = 2;
127int offline_search_filter_duplicates = 0; 127int offline_search_filter_duplicates = 0;
128int offline_search_break_searching = 0; 128int offline_search_break_searching = 0;
129char *navit_maps_dir; 129char *navit_maps_dir;
130char *navit_share_dir;
131char *navit_data_dir;
130int cancel_drawing_global = 0; 132int cancel_drawing_global = 0;
131int global_speak_streetnames = 1; 133int global_speak_streetnames = 1;
132int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now 134int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now
133int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB) 135int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB)
134int draw_polylines_fast = 0; // default: 0 136int draw_polylines_fast = 0; // default: 0
139int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing 141int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing
140int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still 142int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still
141int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles 143int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles
142int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light 144int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light
143int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them 145int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them
146int global_have_dpi_value = 240;
147float global_dpi_factor = 1.0f;
148int global_order_level_for_fast_draw = 13;
149int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map
150 // 1 -> show "normal, english"
151 // 2 -> show only "english" labels
144 152
145GHashTable *global_transform_hash = NULL; 153GHashTable *global_transform_hash = NULL;
146GHashTable *global_transform_hash2 = NULL; 154GHashTable *global_transform_hash2 = NULL;
147 155
148long long draw_lines_count_2 = 0; 156long long draw_lines_count_2 = 0;
149long long draw_lines_count_3 = 0; 157long long draw_lines_count_3 = 0;
150long long draw_lines_count_4 = 0; 158long long draw_lines_count_4 = 0;
159int poi_on_map_count = 0;
160int label_on_map_count = 0;
161int label_district_on_map_count = 0;
162int label_major_on_map_count = 0;
163int poi_icon_on_map_count = 0;
151 164
152int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads] 165int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads]
153int cur_mapdraw_time_index = 0; 166int cur_mapdraw_time_index = 0;
154 167
155int route_status_previous = 0; 168int route_status_previous = 0;
156long long global_route_memory_size = 0; 169long long global_route_memory_size = 0;
170int global_old_vehicle_speed = -1;
171int global_old_vehicle_speed_for_autozoom = -1;
157 172
158void navit_add_mapset(struct navit *this_, struct mapset *ms) 173void navit_add_mapset(struct navit *this_, struct mapset *ms)
159{ 174{
160#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 175#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
161 dbg(0,"+#+:enter\n"); 176 dbg(0,"+#+:enter\n");
211#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 226#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
212 dbg(0,"+#+:enter\n"); 227 dbg(0,"+#+:enter\n");
213#endif 228#endif
214 ////DBG dbg(0,"EEnter\n"); 229 ////DBG dbg(0,"EEnter\n");
215 char *dir; 230 char *dir;
216 dir = getenv("NAVIT_USER_DATADIR"); 231 // dir = getenv("NAVIT_USER_DATADIR");
232 dir = navit_share_dir;
217 if (create && !file_exists(dir)) 233 if (create && !file_exists(dir))
218 { 234 {
219 //DBG dbg(0, "creating dir %s\n", dir); 235 //DBG dbg(0, "creating dir %s\n", dir);
220 if (file_mkdir(dir, 0)) 236 if (file_mkdir(dir, 0))
221 { 237 {
772 // return scale value to android 788 // return scale value to android
773#ifdef HAVE_API_ANDROID 789#ifdef HAVE_API_ANDROID
774 android_return_generic_int(3, (int)scale); 790 android_return_generic_int(3, (int)scale);
775#endif 791#endif
776 792
793 //dbg(0, "zoom to scale=%d", (int)scale);
794
795
777 if (p) 796 if (p)
778 { 797 {
779 transform_reverse(this_->trans, p, &c1); 798 transform_reverse(this_->trans, p, &c1);
780 } 799 }
781 800
808 * @param this_ The navit struct 827 * @param this_ The navit struct
809 * @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle 828 * @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle
810 * @param speed The vehicles speed in meters per second 829 * @param speed The vehicles speed in meters per second
811 * @param dir The direction into which the vehicle moves 830 * @param dir The direction into which the vehicle moves
812 */ 831 */
813static void navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw) 832static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw)
814{ 833{
815#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 834#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
816 dbg(0,"+#+:enter\n"); 835 dbg(0,"+#+:enter\n");
817#endif 836#endif
818 struct point pc; 837 struct point pc;
819 int distance, w, h; 838 int distance, w, h;
820 double new_scale; 839 long new_scale;
821 long scale; 840 long scale;
822 841
823 if (!this_->autozoom_active) 842 if (!this_->autozoom_active)
824 { 843 {
844 return -1;
845 }
846
847 if (global_old_vehicle_speed < 1)
848 {
849 return -1;
850 }
851
852 if (speed < 20)
853 {
854 return -1;
855 }
856
857// this is kaputt!!
858#if 0
859 if (global_old_vehicle_speed_for_autozoom > 0)
860 {
861 if (abs(global_old_vehicle_speed_for_autozoom - speed) < 10)
862 {
863 // change in speed not significant
825 return; 864 return;
826 } 865 }
866 }
867 global_old_vehicle_speed_for_autozoom = speed;
868#endif
869// this is kaputt!!
827 870
828 distance = speed * this_->autozoom_secs; 871 // distance = speed * this_->autozoom_secs;
872 if (speed > 109)
873 {
874 distance = speed * 10;
875 }
876 else
877 {
878 distance = speed * 5;
879 }
880
881 // scale = this_->trans->scale * 16;
882 scale = transform_get_scale(this_->trans);
829 883
830 transform_get_size(this_->trans, &w, &h); 884 transform_get_size(this_->trans, &w, &h);
831 transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL); 885 transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL);
832 scale = transform_get_scale(this_->trans); 886
887 //dbg(0,"autozoom: dist=%d\n", distance);
888 //dbg(0,"autozoom: scale=%d\n", (int)scale);
889 //dbg(0,"autozoom:o speed=%d\n", speed);
890 //dbg(0,"autozoom:n speed=%d\n", global_old_vehicle_speed);
833 891
834 /* We make sure that the point we want to see is within a certain range 892 /* We make sure that the point we want to see is within a certain range
835 * around the vehicle. The radius of this circle is the size of the 893 * around the vehicle. The radius of this circle is the size of the
836 * screen. This doesn't necessarily mean the point is visible because of 894 * screen. This doesn't necessarily mean the point is visible because of
837 * perspective etc. Quite rough, but should be enough. */ 895 * perspective etc. Quite rough, but should be enough. */
838 896
839 if (w > h) 897 if (w > h)
840 { 898 {
841 new_scale = (double) distance / h * 16; 899 new_scale = (long)( ((float)distance / (float)h) * 16);
842 } 900 }
843 else 901 else
844 { 902 {
845 new_scale = (double) distance / w * 16; 903 new_scale = (long)( ((float)distance / (float)w) * 16);
846 } 904 }
847 905
906 if (new_scale < this_->autozoom_min)
907 {
908 new_scale = this_->autozoom_min;
909 }
910
911 //dbg(0,"autozoom:w scale=%d\n", (int)new_scale);
912
848 if (abs(new_scale - scale) < 2) 913 //if (abs(new_scale - scale) < 2)
849 { 914 //{
850 return; // Smoothing 915 // return; // Smoothing
851 } 916 //}
852 917
853 if (new_scale >= this_->autozoom_min) 918 if (new_scale > scale)
919 {
920 if (new_scale > (scale + 20))
854 { 921 {
855 navit_scale(this_, (long) new_scale, &pc, 0); 922 scale = scale + 10;
923 }
924 else if (new_scale > (scale + 5))
925 {
926 scale = scale + 4;
927 }
928 else
929 {
930 scale = scale++;
931 }
932 }
933 else if (new_scale < scale)
934 {
935 if ((new_scale + 20) < scale)
936 {
937 scale = scale - 10;
938 }
939 else if ((new_scale + 5) < scale)
940 {
941 scale = scale - 4;
942 }
943 else
944 {
945 scale = scale--;
946 }
856 } 947 }
857 else 948 else
858 { 949 {
950 // no change
951 return -1;
952 }
953
954 //dbg(0,"autozoom:n scale=%d\n", (int)scale);
955
956 if (scale >= this_->autozoom_min)
957 {
958 navit_scale(this_, (long) scale, &pc, 0);
959 }
960 else
961 {
859 if (scale != this_->autozoom_min) 962 //if (scale != this_->autozoom_min)
860 { 963 //{
861 navit_scale(this_, this_->autozoom_min, &pc, 0); 964 navit_scale(this_, this_->autozoom_min, &pc, 0);
965 //}
862 } 966 }
863 } 967
968 // return new scale value
969 return scale;
864} 970}
865 971
866/** 972/**
867 * Change the current zoom level, zooming closer to the ground 973 * Change the current zoom level, zooming closer to the ground
868 * 974 *
877 dbg(0,"+#+:enter\n"); 983 dbg(0,"+#+:enter\n");
878#endif 984#endif
879 ////DBG dbg(0,"EEnter\n"); 985 ////DBG dbg(0,"EEnter\n");
880 long scale = transform_get_scale(this_->trans) / factor; 986 long scale = transform_get_scale(this_->trans) / factor;
881 if (scale < 1) 987 if (scale < 1)
988 {
882 scale = 1; 989 scale = 1;
990 }
883 ////DBG dbg(0,"zoom in -> scale=%d",scale); 991 ////DBG dbg(0,"zoom in -> scale=%d",scale);
884 navit_scale(this_, scale, p, 1); 992 navit_scale(this_, scale, p, 1);
885} 993}
886 994
887/** 995/**
923 { 1031 {
924 navit_zoom_in(this_, factor, &p); 1032 navit_zoom_in(this_, factor, &p);
925 this_->vehicle->follow_curr = this_->vehicle->follow; 1033 this_->vehicle->follow_curr = this_->vehicle->follow;
926 } 1034 }
927 else 1035 else
1036 {
928 navit_zoom_in(this_, factor, NULL); 1037 navit_zoom_in(this_, factor, NULL);
1038 }
929} 1039}
930 1040
931void navit_zoom_to_scale(struct navit *this_, int new_scale) 1041void navit_zoom_to_scale(struct navit *this_, int new_scale)
932{ 1042{
933#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1043#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
955 dbg(0,"+#+:enter\n"); 1065 dbg(0,"+#+:enter\n");
956#endif 1066#endif
957 //DBG dbg(0,"EEnter\n"); 1067 //DBG dbg(0,"EEnter\n");
958 long scale = transform_get_scale(this_->trans); 1068 long scale = transform_get_scale(this_->trans);
959 long new_scale_long = new_scale; 1069 long new_scale_long = new_scale;
1070
960 // dbg(0, "zoom to scale -> old scale=%d", scale); 1071 //dbg(0, "zoom to scale -> old scale=%d", scale);
961 // dbg(0, "zoom to scale -> want scale=%d", new_scale_long); 1072 //dbg(0, "zoom to scale -> want scale=%d", new_scale_long);
962 1073
963 // only do something if scale changed! 1074 // only do something if scale changed!
964 if (scale != new_scale_long) 1075 if (scale != new_scale_long)
965 { 1076 {
966 navit_scale(this_, new_scale_long, p, 1); 1077 navit_scale(this_, new_scale_long, p, 1);
978 { 1089 {
979 navit_zoom_out(this_, 2, &p); 1090 navit_zoom_out(this_, 2, &p);
980 this_->vehicle->follow_curr = this_->vehicle->follow; 1091 this_->vehicle->follow_curr = this_->vehicle->follow;
981 } 1092 }
982 else 1093 else
1094 {
983 navit_zoom_out(this_, 2, NULL); 1095 navit_zoom_out(this_, 2, NULL);
1096 }
984} 1097}
985 1098
986static int navit_cmd_zoom_in(struct navit *this_) 1099static int navit_cmd_zoom_in(struct navit *this_)
987{ 1100{
988#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 1101#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1718 1831
1719 // changed default to 1 1832 // changed default to 1
1720 this_->center_timeout = 1; 1833 this_->center_timeout = 1;
1721 this_->use_mousewheel = 1; 1834 this_->use_mousewheel = 1;
1722 this_->autozoom_secs = 10; 1835 this_->autozoom_secs = 10;
1723 this_->autozoom_min = 7; 1836 this_->autozoom_min = 6;
1724 this_->autozoom_active = 0; 1837 this_->autozoom_active = 0;
1725 this_->zoom_min = 1; 1838 this_->zoom_min = 1;
1726 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3; 1839 this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3;
1727 this_->follow_cursor = 1; 1840 this_->follow_cursor = 1;
1728 this_->radius = 30; 1841 this_->radius = 30;
2430 //if (global_navit->destination_valid != 0) 2543 //if (global_navit->destination_valid != 0)
2431 //{ 2544 //{
2432 navit_set_destination(global_navit, NULL, NULL, 0); 2545 navit_set_destination(global_navit, NULL, NULL, 0);
2433 //} 2546 //}
2434 2547
2548
2549 if (this_->tracking)
2550 {
2551 tracking_flush(this_->tracking);
2552 }
2435 2553
2436 if (this_->route) 2554 if (this_->route)
2437 { 2555 {
2438 struct attr callback; 2556 struct attr callback;
2439 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 2557 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
2621 mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/borders.bin"); 2739 mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/borders.bin");
2622 struct attr active; 2740 struct attr active;
2623 active.type = attr_active; 2741 active.type = attr_active;
2624 active.u.num = 0; 2742 active.u.num = 0;
2625 //map_set_attr(map2, &active); 2743 //map_set_attr(map2, &active);
2744
2745 active.type = attr_route_active;
2746 active.u.num = 0; // by default deactivate rounting on this map
2747 map_set_attr(map2, &active);
2626 } 2748 }
2627 g_free(map_file); 2749 g_free(map_file);
2628 2750
2629 parent.type = attr_navit; 2751 parent.type = attr_navit;
2630 parent.u.navit = this_; 2752 parent.u.navit = this_;
2651 mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/coastline.bin"); 2773 mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/coastline.bin");
2652 struct attr active; 2774 struct attr active;
2653 active.type = attr_active; 2775 active.type = attr_active;
2654 active.u.num = 0; 2776 active.u.num = 0;
2655 //map_set_attr(map2, &active); 2777 //map_set_attr(map2, &active);
2778
2779 active.type = attr_route_active;
2780 active.u.num = 0; // by default deactivate rounting on this map
2781 map_set_attr(map2, &active);
2656 } 2782 }
2657 g_free(map_file); 2783 g_free(map_file);
2658 2784
2659 // gpx tracks map -------------------- 2785 // gpx tracks map --------------------
2660 parent.type = attr_navit; 2786 parent.type = attr_navit;
2712 active.u.num = 0; 2838 active.u.num = 0;
2713 //map_set_attr(map2, &active); 2839 //map_set_attr(map2, &active);
2714 } 2840 }
2715 g_free(map_file); 2841 g_free(map_file);
2716 // traffic map -------------------- 2842 // traffic map --------------------
2843
2844
2845
2846 // world map2 --------------------
2847 parent.type = attr_navit;
2848 parent.u.navit = this_;
2849 type.type = attr_type;
2850 type.u.str = "textfile";
2851 data.type = attr_data;
2852 map_file = g_strdup_printf("%sworldmap2.txt", navit_maps_dir);
2853 data.u.str = map_file;
2854
2855 dbg(0, "activate map:%s\n", map_file);
2856
2857 flags.type = attr_flags;
2858 flags.u.num = 0;
2859 attrs[0] = &type;
2860 attrs[1] = &data;
2861 attrs[2] = &flags;
2862 attrs[3] = NULL;
2863 map2 = map_new(&parent, attrs);
2864 if (map2)
2865 {
2866 map2_attr.u.data = map2;
2867 map2_attr.type = attr_map;
2868 mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap2.txt");
2869 struct attr active;
2870 active.type = attr_active;
2871 active.u.num = 1; // by default activate map
2872 // map_set_attr(map2, &active);
2873
2874 active.type = attr_route_active;
2875 active.u.num = 0; // by default deactivate routing on this map
2876 map_set_attr(map2, &active);
2877
2878 }
2879 g_free(map_file);
2880 // world map2 --------------------
2881
2882
2883 // world map5 --------------------
2884 parent.type = attr_navit;
2885 parent.u.navit = this_;
2886 type.type = attr_type;
2887 type.u.str = "textfile";
2888 data.type = attr_data;
2889 map_file = g_strdup_printf("%sworldmap5.txt", navit_maps_dir);
2890 data.u.str = map_file;
2891
2892 dbg(0, "activate map:%s\n", map_file);
2893
2894 flags.type = attr_flags;
2895 flags.u.num = 0;
2896 attrs[0] = &type;
2897 attrs[1] = &data;
2898 attrs[2] = &flags;
2899 attrs[3] = NULL;
2900 map2 = map_new(&parent, attrs);
2901 if (map2)
2902 {
2903 map2_attr.u.data = map2;
2904 map2_attr.type = attr_map;
2905 mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap5.txt");
2906 struct attr active;
2907 active.type = attr_active;
2908 active.u.num = 1; // by default activate map
2909 // map_set_attr(map2, &active);
2910
2911 active.type = attr_route_active;
2912 active.u.num = 0; // by default deactivate routing on this map
2913 map_set_attr(map2, &active);
2914 }
2915 g_free(map_file);
2916 // world map5 --------------------
2917
2918
2919#if 0
2920 // world map6 --------------------
2921 parent.type = attr_navit;
2922 parent.u.navit = this_;
2923 type.type = attr_type;
2924 type.u.str = "textfile";
2925 data.type = attr_data;
2926 map_file = g_strdup_printf("%sworldmap6.txt", navit_maps_dir);
2927 data.u.str = map_file;
2928
2929 dbg(0, "activate map:%s\n", map_file);
2930
2931 flags.type = attr_flags;
2932 flags.u.num = 0;
2933 attrs[0] = &type;
2934 attrs[1] = &data;
2935 attrs[2] = &flags;
2936 attrs[3] = NULL;
2937 map2 = map_new(&parent, attrs);
2938 if (map2)
2939 {
2940 map2_attr.u.data = map2;
2941 map2_attr.type = attr_map;
2942 mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap6.txt");
2943 struct attr active;
2944 active.type = attr_active;
2945 active.u.num = 1; // by default activate map
2946 // map_set_attr(map2, &active);
2947
2948 active.type = attr_route_active;
2949 active.u.num = 0; // by default deactivate routing on this map
2950 map_set_attr(map2, &active);
2951 }
2952 g_free(map_file);
2953 // world map6 --------------------
2954#endif
2717 2955
2718 2956
2719 int i = 1; 2957 int i = 1;
2720 for (i = 1; i < 10; i++) 2958 for (i = 1; i < 10; i++)
2721 { 2959 {
3214#endif 3452#endif
3215 ////DBG dbg(0,"EEnter\n"); 3453 ////DBG dbg(0,"EEnter\n");
3216 struct coord *c = transform_center(this_->trans); 3454 struct coord *c = transform_center(this_->trans);
3217 struct coord c1, c2; 3455 struct coord c1, c2;
3218 enum projection pro = transform_get_projection(this_->trans); 3456 enum projection pro = transform_get_projection(this_->trans);
3457
3219 if (pro != center->pro) 3458 if (pro != center->pro)
3220 { 3459 {
3221 c1.x = center->x; 3460 c1.x = center->x;
3222 c1.y = center->y; 3461 c1.y = center->y;
3223 transform_from_to(&c1, center->pro, &c2, pro); 3462 transform_from_to(&c1, center->pro, &c2, pro);
3225 else 3464 else
3226 { 3465 {
3227 c2.x = center->x; 3466 c2.x = center->x;
3228 c2.y = center->y; 3467 c2.y = center->y;
3229 } 3468 }
3469
3230 *c = c2; 3470 *c = c2;
3231 if (set_timeout) 3471 if (set_timeout)
3232 { 3472 {
3233 navit_set_timeout(this_); 3473 navit_set_timeout(this_);
3234 } 3474 }
3475
3235 if (this_->ready == 3) 3476 if (this_->ready == 3)
3236 { 3477 {
3237 navit_draw(this_); 3478 navit_draw(this_);
3238 } 3479 }
3239} 3480}
3397 struct point pn; 3638 struct point pn;
3398 struct navit_vehicle *nv = this_->vehicle; 3639 struct navit_vehicle *nv = this_->vehicle;
3399 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); 3640 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
3400 transform_set_yaw(this_->trans, dir); 3641 transform_set_yaw(this_->trans, dir);
3401 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); 3642 navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
3402 if (autozoom)
3403 {
3404 navit_autozoom(this_, &nv->coord, nv->speed, 0); 3643 // OLD // navit_autozoom(this_, &nv->coord, nv->speed, 0);
3405 }
3406} 3644}
3407 3645
3408static void navit_set_center_cursor_draw(struct navit *this_) 3646static void navit_set_center_cursor_draw(struct navit *this_)
3409{ 3647{
3410#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 3648#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3934 //dbg(0,"layer name=%s\n", layer->name); 4172 //dbg(0,"layer name=%s\n", layer->name);
3935 // only change the zoom of these layers 4173 // only change the zoom of these layers
3936 if ((!strcmp(layer->name, "polygons001")) 4174 if ((!strcmp(layer->name, "polygons001"))
3937 || (!strcmp(layer->name, "polygons")) 4175 || (!strcmp(layer->name, "polygons"))
3938 || (!strcmp(layer->name, "streets")) 4176 || (!strcmp(layer->name, "streets"))
4177 || (!strcmp(layer->name, "streets_STR_ONLY"))
3939 || (!strcmp(layer->name, "streets_1")) 4178 || (!strcmp(layer->name, "streets_1"))
4179 || (!strcmp(layer->name, "streets_1_STR_ONLY"))
3940 || (!strcmp(layer->name, "streets_2")) 4180 || (!strcmp(layer->name, "streets_2"))
4181 || (!strcmp(layer->name, "streets_2_STR_ONLY"))
3941 || (!strcmp(layer->name, "route_001")) 4182 || (!strcmp(layer->name, "route_001"))
3942 || (!strcmp(layer->name, "route_002")) 4183 || (!strcmp(layer->name, "route_002"))
4184 || (!strcmp(layer->name, "route_003"))
3943 ) 4185 )
3944 { 4186 {
3945 //dbg(0,"layer found\n"); 4187 //dbg(0,"layer found\n");
3946 ig = layer->itemgras; 4188 ig = layer->itemgras;
3947 while (ig) 4189 while (ig)
4050#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4292#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4051 dbg(0,"+#+:leave\n"); 4293 dbg(0,"+#+:leave\n");
4052#endif 4294#endif
4053} 4295}
4054 4296
4297void displaylist_shift_for_dpi_value_in_layers(struct navit *this_, double factor)
4298{
4299#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4300 dbg(0,"+#+:enter\n");
4301#endif
4302
4303 GList *l;
4304 struct layout *lay;
4305 GList *l2;
4306 struct layer *layer;
4307 GList *ig;
4308 struct itemgra *itemgr;
4309 GList *elements;
4310 struct element *e;
4311
4312 // loop through all the layouts
4313 l = this_->layouts;
4314 while (l)
4315 {
4316 lay = l->data;
4317 //dbg(0,"layout name=%s\n", lay->name);
4318 if (!strcmp(lay->name, "Android-Car"))
4319 {
4320 //dbg(0,"layout found\n");
4321 l2 = lay->layers;
4322 while (l2)
4323 {
4324 layer = l2->data;
4325 //dbg(0,"layer name=%s\n", layer->name);
4326 // only change the zoom of these layers
4327/*
4328 if ((!strcmp(layer->name, "polygons001"))
4329 || (!strcmp(layer->name, "polygons"))
4330 || (!strcmp(layer->name, "streets"))
4331 || (!strcmp(layer->name, "streets_1"))
4332 || (!strcmp(layer->name, "streets_2"))
4333 || (!strcmp(layer->name, "route_001"))
4334 || (!strcmp(layer->name, "route_002"))
4335 || (!strcmp(layer->name, "route_003"))
4336 )
4337*/
4338 //{
4339 //dbg(0,"layer found\n");
4340 ig = layer->itemgras;
4341 while (ig)
4342 {
4343 //dbg(0,"*itgr*\n");
4344 itemgr = ig->data;
4345
4346 // loop thru all the elements in this "itemgra"
4347 elements = itemgr->elements;
4348 while (elements)
4349 {
4350 e = elements->data;
4351
4352 if (e->type == element_polyline)
4353 {
4354 // polyline width
4355 e->u.polyline.width = (int)((float)e->u.polyline.width * factor) + 0;
4356 if (e->u.polyline.width < 1)
4357 {
4358 e->u.polyline.width = 1;
4359 }
4360 }
4361
4362 if (e->type == element_circle)
4363 {
4364 // circle witdh
4365 e->u.circle.width = (int)((float)e->u.circle.width * factor) + 0;
4366 if (e->u.circle.width < 1)
4367 {
4368 e->u.circle.width = 1;
4369 }
4370
4371 e->u.circle.radius = (int)((float)e->u.circle.radius * factor) + 0;
4372 if (e->u.circle.radius < 1)
4373 {
4374 e->u.circle.radius = 1;
4375 }
4376
4377 // text size
4378 e->text_size = (int)((float)(e->text_size * factor));
4379 if (e->text_size < 1)
4380 {
4381 e->text_size = 1;
4382 }
4383
4384 }
4385
4386 if (e->type == element_text)
4387 {
4388 // text size
4389 e->text_size = (int)((float)(e->text_size * factor));
4390 if (e->text_size < 1)
4391 {
4392 e->text_size = 1;
4393 }
4394 }
4395 elements = g_list_next(elements);
4396 }
4397 // loop thru all the elements in this "itemgra"
4398 ig = g_list_next(ig);
4399 }
4400 //}
4401 l2 = g_list_next(l2);
4402 }
4403 }
4404 l = g_list_next(l);
4405 }
4406
4407#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4408 dbg(0,"+#+:leave\n");
4409#endif
4410}
4411
4412
4055static int navit_add_log(struct navit *this_, struct log *log) 4413static int navit_add_log(struct navit *this_, struct log *log)
4056{ 4414{
4057#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4415#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4058 dbg(0,"+#+:enter\n"); 4416 dbg(0,"+#+:enter\n");
4059#endif 4417#endif
4271 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1); 4629 cursor_draw(nv->cursor, &pnt2, nv->dir-transform_get_angle(this_->trans, 0), nv->speed > 2, 1);
4272#endif 4630#endif
4273#endif 4631#endif
4274} 4632}
4275 4633
4634
4635
4276// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4636// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4277// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4637// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4278// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4638// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4279static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) 4639static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
4280{ 4640{
4290 struct pcoord cursor_pc; 4650 struct pcoord cursor_pc;
4291 struct point cursor_pnt, *pnt = &cursor_pnt; 4651 struct point cursor_pnt, *pnt = &cursor_pnt;
4292 struct point old_cursor_pnt; 4652 struct point old_cursor_pnt;
4293 struct tracking *tracking = NULL; 4653 struct tracking *tracking = NULL;
4294 struct pcoord pc[16]; 4654 struct pcoord pc[16];
4655
4295 enum projection pro = transform_get_projection(this_->trans_cursor); 4656 enum projection pro = transform_get_projection(this_->trans_cursor);
4657
4296 int count; 4658 int count;
4297 int old_dir; 4659 int old_dir;
4298 int old_pos_invalid; 4660 int old_pos_invalid;
4299 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *); 4661 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
4300 void *attr_object; 4662 void *attr_object;
4301 char *destination_file; 4663 char *destination_file;
4664 long new_scale_value;
4665 long old_scale_value;
4302 4666
4303 if (this_->ready != 3) 4667 if (this_->ready != 3)
4304 { 4668 {
4305 //profile(0,"return 1\n"); 4669 //profile(0,"return 1\n");
4306 return; 4670 return;
4340 // load attrs with data from vehicle 4704 // load attrs with data from vehicle
4341 4705
4342 4706
4343 // save old value 4707 // save old value
4344 old_dir = nv->dir; 4708 old_dir = nv->dir;
4709 global_old_vehicle_speed = nv->speed;
4710 old_scale_value = transform_get_scale(this_->trans);
4345 4711
4346 nv->dir = *attr_dir.u.numd; 4712 nv->dir = *attr_dir.u.numd;
4347 nv->speed = *attr_speed.u.numd; 4713 nv->speed = *attr_speed.u.numd;
4348 4714
4349 // old values --------- 4715 // old values ---------
4358 else 4724 else
4359 { 4725 {
4360 old_pos_invalid = 1; 4726 old_pos_invalid = 1;
4361 } 4727 }
4362 // old values --------- 4728 // old values ---------
4363
4364 4729
4365 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord); 4730 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
4366 4731
4367 // save this position 4732 // save this position
4368 global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat; 4733 global_last_vehicle_pos_geo.lat = attr_pos.u.coord_geo->lat;
4381 // return; 4746 // return;
4382 //} 4747 //}
4383 cursor_pc.x = nv->coord.x; 4748 cursor_pc.x = nv->coord.x;
4384 cursor_pc.y = nv->coord.y; 4749 cursor_pc.y = nv->coord.y;
4385 cursor_pc.pro = pro; 4750 cursor_pc.pro = pro;
4751
4386 if (this_->route) 4752 if (this_->route)
4387 { 4753 {
4388 if (tracking) 4754 if (tracking)
4389 { 4755 {
4390 route_set_position_from_tracking(this_->route, tracking, pro); 4756 route_set_position_from_tracking(this_->route, tracking, pro);
4408 */ 4774 */
4409 4775
4410 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 4776 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
4411 // 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); 4777 // 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);
4412 4778
4779 // ------- AUTOZOOM ---------
4780 new_scale_value = navit_autozoom(this_, &nv->coord, nv->speed, 0);
4781 // ------- AUTOZOOM ---------
4413 4782
4414 if (old_pos_invalid == 0) 4783 if (old_pos_invalid == 0)
4415 { 4784 {
4416 int delta_x = cursor_pnt.x - old_cursor_pnt.x; 4785 int delta_x = cursor_pnt.x - old_cursor_pnt.x;
4417 int delta_y = cursor_pnt.y - old_cursor_pnt.y; 4786 int delta_y = cursor_pnt.y - old_cursor_pnt.y;
4418 int delta_angle = nv->dir - old_dir; 4787 int delta_angle = nv->dir - old_dir;
4788 int delta_zoom = 0;
4789
4790 if (new_scale_value != -1)
4791 {
4792 delta_zoom = (int)(new_scale_value - old_scale_value);
4793 }
4419 4794
4420#ifdef HAVE_API_ANDROID 4795#ifdef HAVE_API_ANDROID
4421 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle); 4796 //dbg(0,"delta x=%d, y=%d, angle=%d\n", delta_x, delta_y, delta_angle);
4422 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle); 4797 set_vehicle_values_to_java_delta(delta_x, delta_y, delta_angle, delta_zoom);
4423#endif 4798#endif
4424 } 4799 }
4425 4800
4426 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border))) 4801 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border)))
4427 { 4802 {
4499 //dbg(0,"location update:draw:end\n"); 4874 //dbg(0,"location update:draw:end\n");
4500 } 4875 }
4501 // draw??????? 4876 // draw???????
4502 } 4877 }
4503 4878
4504 //dbg(0,"navit_vehicle_update_999\n");
4505
4506#ifdef NAVIT_MEASURE_TIME_DEBUG 4879#ifdef NAVIT_MEASURE_TIME_DEBUG
4507 debug_mrp("navit_vehicle_update:", debug_measure_end(s_)); 4880 debug_mrp("navit_vehicle_update:", debug_measure_end(s_));
4508#endif 4881#endif
4509 4882
4510#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4883#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4512#endif 4885#endif
4513} 4886}
4514// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4887// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4515// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4888// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4516// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------ 4889// --- this gets called at every positon update (from GPS, or demo vehicle!!) !! ------
4890
4891
4517 4892
4518 4893
4519/** 4894/**
4520 * Set the position of the vehicle 4895 * Set the position of the vehicle
4521 * 4896 *
5806 dbg(0, "ex 010\n"); 6181 dbg(0, "ex 010\n");
5807 route_destroy(this_->route); 6182 route_destroy(this_->route);
5808 dbg(0, "ex 011\n"); 6183 dbg(0, "ex 011\n");
5809 ms = navit_get_mapset(this_); 6184 ms = navit_get_mapset(this_);
5810 dbg(0, "ex 012\n"); 6185 dbg(0, "ex 012\n");
6186
5811 if (ms) 6187 if (ms)
5812 { 6188 {
5813 mapset_destroy(ms); 6189 mapset_destroy(ms);
5814 } 6190 }
6191
5815 dbg(0, "ex 013\n"); 6192 dbg(0, "ex 013\n");
5816 graphics_free(this_->gra); 6193 graphics_free(this_->gra);
5817 dbg(0, "ex 014\n"); 6194 dbg(0, "ex 014\n");
5818 g_free(this_); 6195 g_free(this_);
5819 dbg(0, "ex 015\n"); 6196 dbg(0, "ex 015\n");

Legend:
Removed from v.33  
changed lines
  Added in v.34

   
Visit the ZANavi Wiki