/[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 46 Revision 47
84 static double gps_last_lon = 0.0d; 84 static double gps_last_lon = 0.0d;
85 static int gps_last_lat_1000 = 0; 85 static int gps_last_lat_1000 = 0;
86 static int gps_last_lon_1000 = 0; 86 static int gps_last_lon_1000 = 0;
87 static int fast_provider_status = 0; 87 static int fast_provider_status = 0;
88 static int disregard_first_fast_location = 0; 88 static int disregard_first_fast_location = 0;
89 static String[] cmd_name = new String[4];
89 90
90 static long MILLIS_AFTER_GPS_FIX_IS_LOST = 2000; 91 static long MILLIS_AFTER_GPS_FIX_IS_LOST = 2000;
91 92
92 static TunnelExtrapolationThread te_thread = null; 93 static TunnelExtrapolationThread te_thread = null;
93 94
305 // --------------------- 306 // ---------------------
306 // --------------------- 307 // ---------------------
307 308
308 vehicle_handler_ = Navit.vehicle_handler; 309 vehicle_handler_ = Navit.vehicle_handler;
309 310
311 cmd_name[0] = "-";
312 cmd_name[1] = "POS";
313 cmd_name[2] = "CLR";
314 cmd_name[3] = "DST";
315
310 locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); 316 locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
311 locationManager_s = locationManager; 317 locationManager_s = locationManager;
312 318
313 LocationListener fastLocationListener = new LocationListener() 319 LocationListener fastLocationListener = new LocationListener()
314 { 320 {
1302 1308
1303 static void pos_recording_start() 1309 static void pos_recording_start()
1304 { 1310 {
1305 is_pos_recording = true; 1311 is_pos_recording = true;
1306 1312
1313 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1307 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording"; 1314 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + date + "-" + "zanavi_pos_recording";
1308 String pos_recording_filename = pos_recording_filename_base + ".txt"; 1315 String pos_recording_filename = pos_recording_filename_base + ".txt";
1309 // String pos_recording_filename_gpx_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording"; 1316 // String pos_recording_filename_gpx_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording";
1310 //String pos_recording_filename_gpx = pos_recording_filename_gpx_base + ".gpx"; 1317 //String pos_recording_filename_gpx = pos_recording_filename_gpx_base + ".gpx";
1311 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date()); 1318 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1312 //String pos_recording_filename_gpx_archive = pos_recording_filename_gpx_base + "_" + date + ".gpx"; 1319 //String pos_recording_filename_gpx_archive = pos_recording_filename_gpx_base + "_" + date + ".gpx";
1392 { 1399 {
1393 // dont save (already saved) log 1400 // dont save (already saved) log
1394 return; 1401 return;
1395 } 1402 }
1396 1403
1404 //System.out.println("PRF:CMD=" + cmd_name[cmd] + " dst=" + Navit.global_last_destination_name);
1405
1397 if (cmd == 0) // empty lines 1406 if (cmd == 0) // empty lines
1398 { 1407 {
1399 try 1408 try
1400 { 1409 {
1401 pos_recording_writer.write("\n"); 1410 pos_recording_writer.write("\n");
1432 } 1441 }
1433 else if (cmd == 2) // CLR 1442 else if (cmd == 2) // CLR
1434 { 1443 {
1435 try 1444 try
1436 { 1445 {
1446 if (time == 111)
1447 {
1448 pos_recording_writer.write("CLR:" + "\"\"" + "\n");
1449 }
1437 1450
1451 if (time == 111)
1452 {
1453
1438 // before "CLR" rotate recording file -------------------------- 1454 // before "CLR" rotate recording file --------------------------
1439 // before "CLR" rotate recording file -------------------------- 1455 // before "CLR" rotate recording file --------------------------
1440 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_pos_recording";
1441 String pos_recording_filename = pos_recording_filename_base + ".txt";
1442 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date()); 1456 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1457 String pos_recording_filename_base = Navit.NAVIT_DATA_DEBUG_DIR + date + "-" + "zanavi_pos_recording";
1458 String pos_recording_filename = pos_recording_filename_base + ".txt";
1443 String pos_recording_filename_archive = pos_recording_filename_base + "_" + date + ".txt"; 1459 String pos_recording_filename_archive = pos_recording_filename_base + "_" + date + ".txt";
1444 1460
1461 //System.out.println("PRF:CLR:" + pos_recording_file.getName() + " " + pos_recording_filename_archive);
1462 pos_recording_filename_archive = Navit.NAVIT_DATA_DEBUG_DIR + "arch_" + pos_recording_file.getName();
1463
1464 //System.out.println("PRF:CLR:004:" + pos_recording_filename_archive);
1465
1445 try 1466 try
1446 { 1467 {
1447 if (pos_recording_file.exists()) 1468 if (pos_recording_file.exists())
1448 { 1469 {
1470 //System.out.println("PRF:CLR:005");
1471
1472 try
1473 {
1449 pos_recording_writer.close(); 1474 pos_recording_writer.close();
1475 }
1476 catch (Exception cl001)
1477 {
1478 }
1450 1479
1451 // archive old GPX file 1480 // archive old GPX file
1452 pos_recording_file.renameTo(new File(pos_recording_filename_archive)); 1481 pos_recording_file.renameTo(new File(pos_recording_filename_archive));
1453 pos_recording_file = new File(pos_recording_filename); 1482 pos_recording_file = new File(pos_recording_filename);
1454 pos_recording_writer = new BufferedWriter(new FileWriter(pos_recording_file, true)); 1483 pos_recording_writer = new BufferedWriter(new FileWriter(pos_recording_file, true));
1484
1485 //System.out.println("PRF:CLR:006");
1455 } 1486 }
1456 } 1487 }
1457 catch (Exception e) 1488 catch (Exception e)
1458 { 1489 {
1459 } 1490 }
1460 // before "CLR" rotate recording file -------------------------- 1491 // before "CLR" rotate recording file --------------------------
1461 // before "CLR" rotate recording file -------------------------- 1492 // before "CLR" rotate recording file --------------------------
1462 1493
1494 //System.out.println("PRF:CLR:007");
1495 }
1496
1497 if (time == 0)
1498 {
1463 pos_recording_writer.write("CLR:" + "\"\"" + "\n"); 1499 pos_recording_writer.write("CLR:" + "\"\"" + "\n");
1500 }
1501
1464 } 1502 }
1465 catch (Exception e) 1503 catch (Exception e)
1466 { 1504 {
1467 } 1505 }
1468 } 1506 }
1470 { 1508 {
1471 try 1509 try
1472 { 1510 {
1473 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN); 1511 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);
1474 String currentDateandTime = sdf.format(new Date()); 1512 String currentDateandTime = sdf.format(new Date());
1513
1514 try
1515 {
1516 //System.out.println("PRF:X01:" + Navit.global_last_destination_name + " " + pos_recording_file.getName());
1517
1518 if ((Navit.global_last_destination_name.compareTo("") != 0) && (pos_recording_file.getName().contains("zanavi_pos_recording")))
1519 {
1520 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1521 String pos_recording_filename_newname = Navit.NAVIT_DATA_DEBUG_DIR + "route-" + date + "-" + Navit.global_last_destination_name + ".txt";
1522
1523 //System.out.println("PRF:X02:" + pos_recording_filename_newname);
1524
1525 if (pos_recording_file.exists())
1526 {
1527 pos_recording_writer.close();
1528 pos_recording_file.renameTo(new File(pos_recording_filename_newname));
1529 pos_recording_file = new File(pos_recording_filename_newname);
1530 pos_recording_writer = new BufferedWriter(new FileWriter(pos_recording_file, true));
1531 }
1532 }
1533 }
1534 catch (Exception e)
1535 {
1536 }
1537
1475 pos_recording_writer.write("REM:" + "\"Date:" + currentDateandTime + "\"" + "\n"); 1538 pos_recording_writer.write("REM:" + "\"Date:" + currentDateandTime + "\"" + "\n");
1476 pos_recording_writer.write("DST:" + "\"" + customNumberFormat_("####.######", lat) + "," + customNumberFormat_("####.######", lon) + "\"" + "\n"); 1539 pos_recording_writer.write("DST:" + "\"" + customNumberFormat_("####.######", lat) + "," + customNumberFormat_("####.######", lon) + "\"" + "\n");
1540 if (Navit.global_last_destination_name.compareTo("") != 0)
1541 {
1542 pos_recording_writer.write("REM:" + "\"TO:" + Navit.global_last_destination_name + "\"" + "\n");
1543 }
1544
1477 } 1545 }
1478 catch (Exception e) 1546 catch (Exception e)
1479 { 1547 {
1480 } 1548 }
1481 } 1549 }

Legend:
Removed from v.46  
changed lines
  Added in v.47

   
Visit the ZANavi Wiki