/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitVehicle.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitVehicle.java

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

Revision 40 Revision 41
58import android.location.LocationProvider; 58import android.location.LocationProvider;
59import android.os.Bundle; 59import android.os.Bundle;
60import android.os.Handler; 60import android.os.Handler;
61import android.os.Message; 61import android.os.Message;
62import android.os.SystemClock; 62import android.os.SystemClock;
63import android.text.format.DateFormat;
63import android.util.Log; 64import android.util.Log;
64 65
65public class NavitVehicle 66public class NavitVehicle
66{ 67{
67 private LocationManager locationManager = null; 68 private LocationManager locationManager = null;
88 89
89 static long MILLIS_AFTER_GPS_FIX_IS_LOST = 2000; 90 static long MILLIS_AFTER_GPS_FIX_IS_LOST = 2000;
90 91
91 static TunnelExtrapolationThread te_thread = null; 92 static TunnelExtrapolationThread te_thread = null;
92 93
94 static boolean is_pos_recording = false;
93 static File pos_recording_file; 95 static File pos_recording_file;
94 // static File pos_recording_file_gpx; 96 // static File pos_recording_file_gpx;
95 static File speech_recording_file_gpx; 97 static File speech_recording_file_gpx;
96 static BufferedWriter pos_recording_writer; 98 static BufferedWriter pos_recording_writer;
97 // static BufferedWriter pos_recording_writer_gpx; 99 // static BufferedWriter pos_recording_writer_gpx;
98 static BufferedWriter speech_recording_writer_gpx; 100 static BufferedWriter speech_recording_writer_gpx;
99 static boolean speech_recording_started = false; 101 static boolean speech_recording_started = false;
102 // DateFormat sdf = new DateFormat();
100 103
101 int sats1_old = -1; 104 int sats1_old = -1;
102 int satsInFix1_old = -1; 105 int satsInFix1_old = -1;
103 106
104 public static Handler vehicle_handler_ = null; 107 public static Handler vehicle_handler_ = null;
153 } 156 }
154 // change bearing/direction to last good bearing ------------------- 157 // change bearing/direction to last good bearing -------------------
155 // change bearing/direction to last good bearing ------------------- 158 // change bearing/direction to last good bearing -------------------
156 // change bearing/direction to last good bearing ------------------- 159 // change bearing/direction to last good bearing -------------------
157 160
158 if (Navit.PREF_enable_debug_write_gpx) 161 if (Navit.p.PREF_enable_debug_write_gpx)
159 { 162 {
160 pos_recording_add(1, location.getLatitude(), location.getLongitude(), location.getSpeed(), location.getBearing(), location.getTime()); 163 pos_recording_add(1, location.getLatitude(), location.getLongitude(), location.getSpeed(), location.getBearing(), location.getTime());
161 } 164 }
162 165
163 if (Navit.NAVIT_DEBUG_TEXT_VIEW) ZANaviOSDDebug01.add_text(dd_text + "b=" + location.getBearing() + " lb=" + gps_last_bearing); 166 if (Navit.NAVIT_DEBUG_TEXT_VIEW) ZANaviOSDDebug01.add_text(dd_text + "b=" + location.getBearing() + " lb=" + gps_last_bearing);
322 last_f_fix = location.getTime(); 325 last_f_fix = location.getTime();
323 // if last gps fix was longer than 8 secs. ago, use this fix 326 // if last gps fix was longer than 8 secs. ago, use this fix
324 // and we dont have a GPS lock 327 // and we dont have a GPS lock
325 if ((last_p_fix + 8000 < last_f_fix) && (Navit.satsInFix < 3)) 328 if ((last_p_fix + 8000 < last_f_fix) && (Navit.satsInFix < 3))
326 { 329 {
327 if (Navit.PREF_follow_gps) 330 if (Navit.p.PREF_follow_gps)
328 { 331 {
329 if (Navit.PREF_use_compass_heading_base) 332 if (Navit.p.PREF_use_compass_heading_base)
330 { 333 {
331 if ((Navit.PREF_use_compass_heading_always) || (location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING)) 334 if ((Navit.p.PREF_use_compass_heading_always) || (location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING))
332 { 335 {
333 // use compass heading 336 // use compass heading
334 location.setBearing(compass_heading); 337 location.setBearing(compass_heading);
335 } 338 }
336 } 339 }
337 340
338 //System.out.println("send values 1"); 341 //System.out.println("send values 1");
339 Log.e("NavitVehicle", "LocationChanged provider=fast Latitude " + location.getLatitude() + " Longitude " + location.getLongitude()); 342 // Log.e("NavitVehicle", "LocationChanged provider=fast Latitude " + location.getLatitude() + " Longitude " + location.getLongitude());
340 last_location = location; 343 last_location = location;
341 if (!Navit.DemoVehicle) 344 if (!Navit.DemoVehicle)
342 { 345 {
343 //Log.e("NavitVehicle", "call VehicleCallback 001"); 346 //Log.e("NavitVehicle", "call VehicleCallback 001");
344 VehicleCallback2(location); 347 VehicleCallback2(location);
394 { 397 {
395 Navit.mLastLocationMillis = SystemClock.elapsedRealtime(); 398 Navit.mLastLocationMillis = SystemClock.elapsedRealtime();
396 Navit.mLastLocation = location; 399 Navit.mLastLocation = location;
397 } 400 }
398 401
399 if (Navit.PREF_follow_gps) 402 if (Navit.p.PREF_follow_gps)
400 { 403 {
401 if (Navit.PREF_use_compass_heading_base) 404 if (Navit.p.PREF_use_compass_heading_base)
402 { 405 {
403 if ((Navit.PREF_use_compass_heading_always) || (location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING)) 406 if ((Navit.p.PREF_use_compass_heading_always) || (location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING))
404 { 407 {
405 // use compass heading 408 // use compass heading
406 location.setBearing(compass_heading); 409 location.setBearing(compass_heading);
407 } 410 }
408 } 411 }
524 { 527 {
525 fastProvider = null; 528 fastProvider = null;
526 } 529 }
527 else 530 else
528 { 531 {
529 if (Navit.PREF_use_fast_provider) 532 if (Navit.p.PREF_use_fast_provider)
530 { 533 {
531 //*in onresume()*//locationManager.requestLocationUpdates(fastProvider, 30000L, 8.0f, fastLocationListener); // (long)time [milliseconds], (float)minDistance [meters] 534 //*in onresume()*//locationManager.requestLocationUpdates(fastProvider, 30000L, 8.0f, fastLocationListener); // (long)time [milliseconds], (float)minDistance [meters]
532 } 535 }
533 } 536 }
534 } 537 }
574 else 577 else
575 { 578 {
576 b.putString("s", "0"); 579 b.putString("s", "0");
577 } 580 }
578 msg.setData(b); 581 msg.setData(b);
579 Navit.N_NavitGraphics.callback_handler.sendMessage(msg); 582 NavitGraphics.callback_handler.sendMessage(msg);
580 } 583 }
581 catch (Exception e) 584 catch (Exception e)
582 { 585 {
583 } 586 }
584 587
585 if (Navit.PREF_show_sat_status) 588 if (Navit.p.PREF_show_sat_status)
586 { 589 {
587 // redraw NavitOSDJava 590 // redraw NavitOSDJava
588 System.out.println("xx paint 10 xx"); 591 // System.out.println("onDraw:show_sat_status:1");
589 NavitGraphics.OSD_new.postInvalidate(); 592 NavitGraphics.OSD_new.postInvalidate();
590 } 593 }
591 594
592 if (Navit.want_tunnel_extrapolation()) 595 if (Navit.want_tunnel_extrapolation())
593 { 596 {
631 // System.out.println("checking sat status update"); 634 // System.out.println("checking sat status update");
632 635
633 if ((sats1_old != Navit.sats) || (satsInFix1_old != Navit.satsInFix)) 636 if ((sats1_old != Navit.sats) || (satsInFix1_old != Navit.satsInFix))
634 { 637 {
635 //System.out.println("sat status update -> changed"); 638 //System.out.println("sat status update -> changed");
636 if (Navit.PREF_show_sat_status) 639 if (Navit.p.PREF_show_sat_status)
637 { 640 {
638 // redraw NavitOSDJava 641 // redraw NavitOSDJava
639 System.out.println("xx paint 11 xx"); 642 // System.out.println("onDraw:show_sat_status:2");
640 NavitGraphics.OSD_new.postInvalidate(); 643 NavitGraphics.OSD_new.postInvalidate();
641 } 644 }
642 } 645 }
643 } 646 }
644 catch (Exception e) 647 catch (Exception e)
661 Message msg = new Message(); 664 Message msg = new Message();
662 Bundle b = new Bundle(); 665 Bundle b = new Bundle();
663 b.putInt("Callback", 102); 666 b.putInt("Callback", 102);
664 b.putString("s", "1"); 667 b.putString("s", "1");
665 msg.setData(b); 668 msg.setData(b);
666 Navit.N_NavitGraphics.callback_handler.sendMessage(msg); 669 NavitGraphics.callback_handler.sendMessage(msg);
667 } 670 }
668 catch (Exception e) 671 catch (Exception e)
669 { 672 {
670 } 673 }
671 674
672 if (Navit.PREF_show_sat_status) 675 if (Navit.p.PREF_show_sat_status)
673 { 676 {
674 // redraw NavitOSDJava 677 // redraw NavitOSDJava
675 System.out.println("xx paint 8 xx"); 678 // System.out.println("onDraw:show_sat_status:3");
676 NavitGraphics.OSD_new.postInvalidate(); 679 NavitGraphics.OSD_new.postInvalidate();
677 } 680 }
678 } 681 }
679 else if (event == GpsStatus.GPS_EVENT_STOPPED) 682 else if (event == GpsStatus.GPS_EVENT_STOPPED)
680 { 683 {
690 Message msg = new Message(); 693 Message msg = new Message();
691 Bundle b = new Bundle(); 694 Bundle b = new Bundle();
692 b.putInt("Callback", 102); 695 b.putInt("Callback", 102);
693 b.putString("s", "0"); 696 b.putString("s", "0");
694 msg.setData(b); 697 msg.setData(b);
695 Navit.N_NavitGraphics.callback_handler.sendMessage(msg); 698 NavitGraphics.callback_handler.sendMessage(msg);
696 } 699 }
697 catch (Exception e) 700 catch (Exception e)
698 { 701 {
699 } 702 }
700 703
701 if (Navit.PREF_show_sat_status) 704 if (Navit.p.PREF_show_sat_status)
702 { 705 {
703 // redraw NavitOSDJava 706 // redraw NavitOSDJava
704 System.out.println("xx paint 9 xx"); 707 // System.out.println("onDraw:show_sat_status:4");
705 NavitGraphics.OSD_new.postInvalidate(); 708 NavitGraphics.OSD_new.postInvalidate();
706 } 709 }
707 } 710 }
708 } 711 }
709 }; 712 };
802 try 805 try
803 { 806 {
804 // If the 2 providers are the same, only activate one listener 807 // If the 2 providers are the same, only activate one listener
805 if (fastProvider_s != null) 808 if (fastProvider_s != null)
806 { 809 {
807 if (Navit.PREF_use_fast_provider) 810 if (Navit.p.PREF_use_fast_provider)
808 { 811 {
809 if (!Navit.DemoVehicle) 812 if (!Navit.DemoVehicle)
810 { 813 {
811 Location l = locationManager_s.getLastKnownLocation(fastProvider_s); 814 Location l = locationManager_s.getLastKnownLocation(fastProvider_s);
812 //System.out.println("ZANAVI:getLastKnownLocation=" + l); 815 //System.out.println("ZANAVI:getLastKnownLocation=" + l);
842 { 845 {
843 if (l.getAccuracy() > 0) 846 if (l.getAccuracy() > 0)
844 { 847 {
845 if ((l.getLatitude() != 0) && (l.getLongitude() != 0)) 848 if ((l.getLatitude() != 0) && (l.getLongitude() != 0))
846 { 849 {
847 if (Navit.PREF_follow_gps) 850 if (Navit.p.PREF_follow_gps)
848 { 851 {
849 Log.e("NavitVehicle", "getLastKnownLocation precise (2) l=" + l.toString()); 852 // Log.e("NavitVehicle", "getLastKnownLocation precise (2) l=" + l.toString());
850 last_location = l; 853 last_location = l;
851 //Log.e("NavitVehicle", "call VehicleCallback 005"); 854 //Log.e("NavitVehicle", "call VehicleCallback 005");
852 VehicleCallback2(l); 855 VehicleCallback2(l);
853 } 856 }
854 } 857 }
861 } 864 }
862 } 865 }
863 866
864 public static void set_last_known_pos_fast_provider() 867 public static void set_last_known_pos_fast_provider()
865 { 868 {
866 System.out.println("fast_provider_status=" + fast_provider_status); 869 // System.out.println("fast_provider_status=" + fast_provider_status);
867 870
868 if (fast_provider_status == 0) 871 if (fast_provider_status == 0)
869 { 872 {
870 return; 873 return;
871 } 874 }
873 try 876 try
874 { 877 {
875 // If the 2 providers are the same, only activate one listener 878 // If the 2 providers are the same, only activate one listener
876 if (fastProvider_s != null) 879 if (fastProvider_s != null)
877 { 880 {
878 if (Navit.PREF_use_fast_provider) 881 if (Navit.p.PREF_use_fast_provider)
879 { 882 {
880 if (!Navit.DemoVehicle) 883 if (!Navit.DemoVehicle)
881 { 884 {
882 Location l = locationManager_s.getLastKnownLocation(fastProvider_s); 885 Location l = locationManager_s.getLastKnownLocation(fastProvider_s);
883 //System.out.println("ZANAVI:getLastKnownLocation=" + l); 886 //System.out.println("ZANAVI:getLastKnownLocation=" + l);
885 { 888 {
886 if (l.getAccuracy() > 0) 889 if (l.getAccuracy() > 0)
887 { 890 {
888 if ((l.getLatitude() != 0) && (l.getLongitude() != 0)) 891 if ((l.getLatitude() != 0) && (l.getLongitude() != 0))
889 { 892 {
890 if (Navit.PREF_follow_gps) 893 if (Navit.p.PREF_follow_gps)
891 { 894 {
892 Log.e("NavitVehicle", "getLastKnownLocation fast (3) l=" + l.toString()); 895 // Log.e("NavitVehicle", "getLastKnownLocation fast (3) l=" + l.toString());
893 last_location = l; 896 last_location = l;
894 //Log.e("NavitVehicle", "call VehicleCallback 006"); 897 //Log.e("NavitVehicle", "call VehicleCallback 006");
895 //System.out.println("ZANAVI:set_last_known_pos_fast_provider"); 898 //System.out.println("ZANAVI:set_last_known_pos_fast_provider");
896 VehicleCallback2(l); 899 VehicleCallback2(l);
897 } 900 }
916 try 919 try
917 { 920 {
918 // If the 2 providers are the same, only activate one listener 921 // If the 2 providers are the same, only activate one listener
919 if (fastProvider_s != null) 922 if (fastProvider_s != null)
920 { 923 {
921 if (Navit.PREF_use_fast_provider) 924 if (Navit.p.PREF_use_fast_provider)
922 { 925 {
923 if (!Navit.DemoVehicle) 926 if (!Navit.DemoVehicle)
924 { 927 {
925 disregard_first_fast_location = 2; 928 disregard_first_fast_location = 2;
926 locationManager_s.requestLocationUpdates(fastProvider_s, 30000L, 8.0f, fastLocationListener_s); // (long)time [milliseconds], (float)minDistance [meters] 929 locationManager_s.requestLocationUpdates(fastProvider_s, 30000L, 8.0f, fastLocationListener_s); // (long)time [milliseconds], (float)minDistance [meters]
955 turn_on_sat_status(); 958 turn_on_sat_status();
956 959
957 try 960 try
958 { 961 {
959 // try to download aGPS data!! 962 // try to download aGPS data!!
960 if (Navit.PREF_use_agps) 963 if (Navit.p.PREF_use_agps)
961 { 964 {
962 Navit.downloadGPSXtra(Navit.getBaseContext_); 965 Navit.downloadGPSXtra(Navit.getBaseContext_);
963 } 966 }
964 } 967 }
965 catch (Exception e) 968 catch (Exception e)
1082 // System.out.println("extrapolated pos:" + extrapolated_post_string); 1085 // System.out.println("extrapolated pos:" + extrapolated_post_string);
1083 String tmp[] = extrapolated_post_string.split(":", 3); 1086 String tmp[] = extrapolated_post_string.split(":", 3);
1084 float lat = Float.parseFloat(tmp[0]); 1087 float lat = Float.parseFloat(tmp[0]);
1085 float lon = Float.parseFloat(tmp[1]); 1088 float lon = Float.parseFloat(tmp[1]);
1086 float dir = Float.parseFloat(tmp[2]); 1089 float dir = Float.parseFloat(tmp[2]);
1087 System.out.println("extrapolated pos:" + lat + " " + lon + " " + dir); 1090 // System.out.println("extrapolated pos:" + lat + " " + lon + " " + dir);
1088 1091
1089 Location l = new Location("ZANavi Tunnel Extrapolation"); 1092 Location l = new Location("ZANavi Tunnel Extrapolation");
1090 l.setLatitude(lat); 1093 l.setLatitude(lat);
1091 l.setLongitude(lon); 1094 l.setLongitude(lon);
1092 l.setBearing(dir); 1095 l.setBearing(dir);
1175 { 1178 {
1176 turn_off_precise_provider(); 1179 turn_off_precise_provider();
1177 turn_off_fast_provider(); 1180 turn_off_fast_provider();
1178 } 1181 }
1179 1182
1180 /*
1181 * public Handler vehicle_handler = new Handler()
1182 * {
1183 * public void handleMessage(Message msg)
1184 * {
1185 * switch (msg.what)
1186 * {
1187 * case 1:
1188 * // dismissDialog(msg.getData().getInt("dialog_num"));
1189 * // removeDialog(msg.getData().getInt("dialog_num"));
1190 * Location l = new Location("Network");
1191 * l.setLatitude(msg.getData().getFloat("lat"));
1192 * l.setLongitude(msg.getData().getFloat("lng"));
1193 * l.setBearing(msg.getData().getFloat("b"));
1194 * l.setSpeed(0.8f);
1195 * NavitVehicle.set_mock_location__fast(l);
1196 * break;
1197 * case 2:
1198 * if (update_location_in_progress)
1199 * {
1200 * }
1201 * else
1202 * {
1203 * update_location_in_progress = true;
1204 * VehicleCallback(last_location);
1205 * update_location_in_progress = false;
1206 * }
1207 * break;
1208 * }
1209 * }
1210 * };
1211 */
1212
1213 public static void update_compass_heading(float heading) 1183 public static void update_compass_heading(float heading)
1214 { 1184 {
1215 compass_heading = heading; 1185 compass_heading = heading;
1216 // use compass heading 1186 // use compass heading
1217 try 1187 try
1218 { 1188 {
1219 if (Navit.PREF_use_compass_heading_base) 1189 if (Navit.p.PREF_use_compass_heading_base)
1220 { 1190 {
1221 if ((Navit.PREF_use_compass_heading_always) || (last_location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING)) 1191 if ((Navit.p.PREF_use_compass_heading_always) || (last_location.getSpeed() < GPS_SPEED_ABOVE_USE_FOR_HEADING))
1222 { 1192 {
1223 if ((lastcompass_update_timestamp + 400) > System.currentTimeMillis()) 1193 if ((lastcompass_update_timestamp + 400) > System.currentTimeMillis())
1224 { 1194 {
1225 //Log.e("NavitVehicle", "compass update to fast!"); 1195 //Log.e("NavitVehicle", "compass update to fast!");
1226 return; 1196 return;
1330 } 1300 }
1331 } 1301 }
1332 1302
1333 static void pos_recording_start() 1303 static void pos_recording_start()
1334 { 1304 {
1305 is_pos_recording = true;
1306
1335 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording"; 1307 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording";
1336 String pos_recording_filename = pos_recording_filename_base + ".txt"; 1308 String pos_recording_filename = pos_recording_filename_base + ".txt";
1337 String pos_recording_filename_gpx_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording"; 1309 // String pos_recording_filename_gpx_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording";
1338 String pos_recording_filename_gpx = pos_recording_filename_gpx_base + ".gpx"; 1310 //String pos_recording_filename_gpx = pos_recording_filename_gpx_base + ".gpx";
1339 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date()); 1311 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1340 String pos_recording_filename_gpx_archive = pos_recording_filename_gpx_base + "_" + date + ".gpx"; 1312 //String pos_recording_filename_gpx_archive = pos_recording_filename_gpx_base + "_" + date + ".gpx";
1341 String pos_recording_filename_archive = pos_recording_filename_base + "_" + date + ".txt"; 1313 //String pos_recording_filename_archive = pos_recording_filename_base + "_" + date + ".txt";
1342 1314
1343 String gpx_header_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" + "<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" + "<metadata>\n" + " <name>ZANavi Debug log</name>\n" + " <desc>ZANavi</desc>\n" + " <author>\n" 1315 // String gpx_header_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" + "<gpx version=\"1.1\" creator=\"ZANavi http://zanavi.cc\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" + "<metadata>\n" + " <name>ZANavi Debug log</name>\n" + " <desc>ZANavi</desc>\n" + " <author>\n"
1344 + " <name>ZANavi</name>\n" + " </author>\n" + "</metadata>\n" + "<trk>\n" + "<trkseg>\n" + " <name>ACTIVE LOG</name>\n"; 1316 // + " <name>ZANavi</name>\n" + " </author>\n" + "</metadata>\n" + "<trk>\n" + "<trkseg>\n" + " <name>ACTIVE LOG</name>\n";
1345 1317
1346 pos_recording_file = new File(pos_recording_filename); 1318 pos_recording_file = new File(pos_recording_filename);
1347 //pos_recording_file_gpx = new File(pos_recording_filename_gpx); 1319 //pos_recording_file_gpx = new File(pos_recording_filename_gpx);
1348 1320
1349 // try 1321 // try
1368 } 1340 }
1369 } 1341 }
1370 1342
1371 static void pos_recording_end() 1343 static void pos_recording_end()
1372 { 1344 {
1345 is_pos_recording = false;
1373 1346
1374 String gpx_trailer_1 = "</trkseg>\n" + "</trk>\n" + "</gpx>\n"; 1347 // String gpx_trailer_1 = "</trkseg>\n" + "</trk>\n" + "</gpx>\n";
1375 1348
1376 try 1349 try
1377 { 1350 {
1378 //pos_recording_writer_gpx.write(gpx_trailer_1); 1351 //pos_recording_writer_gpx.write(gpx_trailer_1);
1379 1352
1399 1372
1400 static void speech_recording_add(double lat, double lon, String text, long time) 1373 static void speech_recording_add(double lat, double lon, String text, long time)
1401 { 1374 {
1402 try 1375 try
1403 { 1376 {
1377 String date_time_gpx = (String) DateFormat.format("yyyy-MM-dd'T'HH:mm:ss'Z'", time);
1378 // System.out.println("33XX"+date_time_gpx+"YY");
1379
1404 // speech_recording_writer_gpx.write(" <trkpt lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><time>2014-10-02T09:30:10Z</time><speed>" + customNumberFormat_("####.##", speed) + "</speed><course>" + customNumberFormat_("####.#", bearing) + "</course></trkpt>\n"); 1380 // speech_recording_writer_gpx.write(" <trkpt lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><time>2014-10-02T09:30:10Z</time><speed>" + customNumberFormat_("####.##", speed) + "</speed><course>" + customNumberFormat_("####.#", bearing) + "</course></trkpt>\n");
1405 // speech_recording_writer_gpx.write(" <rtept lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><name>" + text + "</name></rtept>" + "\n"); 1381 // speech_recording_writer_gpx.write(" <rtept lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><name>" + text + "</name></rtept>" + "\n");
1406 speech_recording_writer_gpx.write(" <wpt lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><time>2014-10-02T09:30:10Z</time>" + "<name>" + text + "</name><sym>Dot</sym><type>Dot</type></wpt>" + "\n"); 1382 speech_recording_writer_gpx.write(" <wpt lat=\"" + customNumberFormat_("####.######", lat) + "\" lon=\"" + customNumberFormat_("####.######", lon) + "\"><time>" + date_time_gpx + "</time>" + "<name>" + text + "</name><sym>Dot</sym><type>Dot</type></wpt>" + "\n");
1407 } 1383 }
1408 catch (Exception e) 1384 catch (Exception e)
1409 { 1385 {
1410 } 1386 }
1411 } 1387 }
1443 // } 1419 // }
1444 1420
1445 try 1421 try
1446 { 1422 {
1447 pos_recording_writer.write("POS:" + "\"" + customNumberFormat_("####.######", lat) + "," + customNumberFormat_("####.######", lon) + "," + customNumberFormat_("####.##", speed) + "," + customNumberFormat_("####.##", bearing) + "\"" + "\n"); 1423 pos_recording_writer.write("POS:" + "\"" + customNumberFormat_("####.######", lat) + "," + customNumberFormat_("####.######", lon) + "," + customNumberFormat_("####.##", speed) + "," + customNumberFormat_("####.##", bearing) + "\"" + "\n");
1424 if (Navit.OSD_route_001.arriving_time_valid)
1425 {
1426 pos_recording_writer.write("REM:" + "\"ETA:" + Navit.OSD_route_001.arriving_time + "\"" + "\n");
1427 }
1448 } 1428 }
1449 catch (Exception e) 1429 catch (Exception e)
1450 { 1430 {
1451 } 1431 }
1452 } 1432 }
1499 { 1479 {
1500 } 1480 }
1501 } 1481 }
1502 } 1482 }
1503 1483
1484 static int distanceBetween(float lat1, float lon1, float lat2, float lon2)
1485 {
1486 int ret = -1;
1487
1488 float[] res = new float[3];
1489
1490 try
1491 {
1492 android.location.Location.distanceBetween(lat1, lon1, lat2, lon2, res);
1493 ret = (int) (res[0]);
1494 }
1495 catch (Exception e)
1496 {
1497 }
1498
1499 return ret;
1500 }
1501
1502 static int distanceBetween(double lat1, double lon1, double lat2, double lon2)
1503 {
1504 int ret = -1;
1505
1506 float[] res = new float[3];
1507
1508 try
1509 {
1510 android.location.Location.distanceBetween(lat1, lon1, lat2, lon2, res);
1511 ret = (int) (res[0]);
1512 }
1513 catch (Exception e)
1514 {
1515 }
1516
1517 return ret;
1518 }
1519
1504} 1520}

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

   
Visit the ZANavi Wiki