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

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/ZANaviDebugReceiver.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (show annotations) (download)
Wed Jun 22 07:33:35 2016 UTC (7 years, 9 months ago) by zoff99
File size: 67450 byte(s)
v2.0.51
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2014 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 package com.zoffcc.applications.zanavi;
21
22 import java.io.BufferedReader;
23 import java.io.File;
24 import java.io.FileOutputStream;
25 import java.io.FileReader;
26 import java.io.FilenameFilter;
27 import java.io.OutputStreamWriter;
28 import java.net.URLEncoder;
29 import java.text.SimpleDateFormat;
30 import java.util.Arrays;
31 import java.util.Date;
32 import java.util.Locale;
33
34 import android.content.BroadcastReceiver;
35 import android.content.Context;
36 import android.content.Intent;
37 import android.location.Location;
38 import android.os.Bundle;
39 import android.os.Message;
40 import android.view.inputmethod.InputMethodManager;
41
42 public class ZANaviDebugReceiver extends BroadcastReceiver
43 {
44
45 static boolean stop_me = false;
46 static boolean dont_save_loc = false;
47
48 private static int skip_count = 0;
49 private static int rewind_count = 0;
50 final private static int skip = 30;
51 static boolean is_replaying = false;
52 static boolean flag_route_ready = false;
53 static String file_name_global = "";
54
55 static String success_source = "";
56 static String success_item = "";
57 static String success_value = "";
58 static String success_operator = "";
59 static int result_code = -1;
60 static int local_meters_value = 0;
61
62 static int yaml_sum = 0;
63 static int yaml_err = 0;
64
65 /*
66 *
67 * Examples:
68 *
69 * (params: "lat, lon")
70 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_position2 "48.656, 15.6777"
71 *
72 * lat, lon, speed (m/s), direction (degrees)
73 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_position "48.656, 15.6777, 12, -75"
74 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es add_destination "48.656, 15.6777"
75 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es clear_route ""
76 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es disable_normal_location ""
77 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es enable_normal_location ""
78 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es export_route_gpx ""
79 *
80 *
81 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_pos_and_dest "Via_Graf 9.1439748 45.5133242 9.1391345 45.5146592"
82 *
83 * -
84 */
85
86 static void enable_normal_location()
87 {
88 Navit.runOnUI(new Runnable()
89 {
90 @Override
91 public void run()
92 {
93 System.out.println("ZANaviDebugReceiver:" + "ENABLE normal location");
94
95 if (Navit.p.PREF_use_fast_provider)
96 {
97 NavitVehicle.turn_on_fast_provider();
98 }
99 else
100 {
101 NavitVehicle.turn_off_fast_provider();
102 }
103
104 // activate gps AFTER 3g-location
105 NavitVehicle.turn_on_precise_provider();
106 }
107 });
108 }
109
110 static void disable_normal_location()
111 {
112 Navit.runOnUI(new Runnable()
113 {
114 @Override
115 public void run()
116 {
117 NavitVehicle.turn_off_all_providers();
118 NavitVehicle.turn_off_sat_status();
119 System.out.println("ZANaviDebugReceiver:" + "disable normal location");
120 }
121 });
122 }
123
124 static void DR_add_destination(String key, Bundle extras)
125 {
126 Object value = extras.get(key);
127 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
128 float lat = Float.parseFloat(value2.split(",", 2)[0]);
129 float lon = Float.parseFloat(value2.split(",", 2)[1]);
130
131 if (NavitGraphics.navit_route_status == 0)
132 {
133 Navit.destination_set();
134
135 Message msg = new Message();
136 Bundle b = new Bundle();
137 b.putInt("Callback", 3);
138 b.putString("lat", String.valueOf(lat));
139 b.putString("lon", String.valueOf(lon));
140 b.putString("q", "DEST 001");
141 msg.setData(b);
142 NavitGraphics.callback_handler.sendMessage(msg);
143 }
144 else
145 {
146 Message msg = new Message();
147 Bundle b = new Bundle();
148 b.putInt("Callback", 48);
149 b.putString("lat", String.valueOf(lat));
150 b.putString("lon", String.valueOf(lon));
151 b.putString("q", "DEST");
152 msg.setData(b);
153 NavitGraphics.callback_handler.sendMessage(msg);
154 }
155
156 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
157 }
158
159 static void DR_set_position(String key, Bundle extras, boolean disable_loc)
160 {
161 if (disable_loc)
162 {
163 disable_normal_location();
164 }
165
166 Object value = extras.get(key);
167 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
168 float lat = Float.parseFloat(value2.split(",", 4)[0]);
169 float lon = Float.parseFloat(value2.split(",", 4)[1]);
170 float speed = Float.parseFloat(value2.split(",", 4)[2]);
171 float direction = Float.parseFloat(value2.split(",", 4)[3]);
172 if (direction < 0)
173 {
174 direction = direction + 360;
175 }
176 else if (direction > 360)
177 {
178 direction = direction - 360;
179 }
180
181 Message msg = new Message();
182 Bundle b = new Bundle();
183 b.putInt("Callback", 97);
184 b.putString("lat", String.valueOf(lat));
185 b.putString("lon", String.valueOf(lon));
186 b.putString("q", "POSITION");
187 msg.setData(b);
188 // *DISABLE* Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
189
190 Location l = new Location("ZANavi Comm");
191 // if (NavitVehicle.fastProvider_s == null)
192 // {
193 // l = new Location("ZANavi Comm");
194 // }
195 // else
196 // {
197 // l = new Location(NavitVehicle.fastProvider_s);
198 // }
199 l.setLatitude(lat);
200 l.setLongitude(lon);
201 l.setBearing(direction);
202 l.setSpeed(speed);
203 l.setAccuracy(4.0f); // accuracy 4 meters
204 // NavitVehicle.update_compass_heading(direction);
205 NavitVehicle.set_mock_location__fast(l);
206
207 // System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
208 // System.out.println("ZANaviDebugReceiver:" + "speed=" + speed + " dir=" + direction);
209 }
210
211 static void DR_save_route_to_gpx_file()
212 {
213 Message msg = new Message();
214 Bundle b = new Bundle();
215 b.putInt("Callback", 96);
216 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
217 String filename = Navit.NAVIT_DATA_DEBUG_DIR + "/zanavi_route_" + date + ".gpx";
218 b.putString("s", filename);
219 msg.setData(b);
220 NavitGraphics.callback_handler.sendMessage(msg);
221 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
222 }
223
224 static void DR_save_route_to_gpx_file_with_name(String name)
225 {
226 Message msg = new Message();
227 Bundle b = new Bundle();
228 b.putInt("Callback", 96);
229 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
230 String filename = name;
231 b.putString("s", filename);
232 msg.setData(b);
233 NavitGraphics.callback_handler.sendMessage(msg);
234 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
235 }
236
237 static void DR_clear_route()
238 {
239 // clear any previous destinations
240 Message msg2 = new Message();
241 Bundle b2 = new Bundle();
242 b2.putInt("Callback", 7);
243 msg2.setData(b2);
244 NavitGraphics.callback_handler.sendMessage(msg2);
245 System.out.println("ZANaviDebugReceiver:" + "clear route");
246 }
247
248 static void DR_rewind_small()
249 {
250 rewind_count = 20;
251 System.out.println("ZANaviDebugReceiver:" + "rewind_small");
252 }
253
254 static void DR_skip()
255 {
256 skip_count = 0;
257 System.out.println("ZANaviDebugReceiver:" + "skip");
258 }
259
260 static double lat_pos = 0.0;
261 static double lon_pos = 0.0;
262 static double lat_dst = 0.0;
263 static double lon_dst = 0.0;
264 static double heading_pos = 0.0;
265
266 static void DR_replay_yaml_file(String filename, final String date)
267 {
268
269 file_name_global = filename;
270
271 yaml_err++; // incr. error count (on success later -> decrease it again)
272
273 try
274 {
275 if ((filename != null) && (!filename.equals("")))
276 {
277 BufferedReader br = null;
278 br = new BufferedReader(new FileReader(filename));
279
280 is_replaying = true;
281 NavitGraphics.NavitAOverlay_s.postInvalidate();
282
283 disable_normal_location();
284
285 String mode = "-";
286 lat_pos = 0.0;
287 lon_pos = 0.0;
288 lat_dst = 0.0;
289 lon_dst = 0.0;
290 heading_pos = 0.0;
291
292 String line = "";
293 while ((line = br.readLine()) != null)
294 {
295 if ((line.length() >= "from:".length()) && (line.equals("from:")))
296 {
297 mode = "from";
298 }
299 else if ((line.length() >= "to:".length()) && (line.equals("to:")))
300 {
301 mode = "to";
302 }
303 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
304 {
305 mode = "success";
306 }
307 else if ((line.length() >= "capture:".length()) && (line.equals("capture:")))
308 {
309 mode = "capture";
310 }
311 else if ((line.length() > 2) && (!line.startsWith("#")))
312 {
313 try
314 {
315 if (mode == "success")
316 {
317 /*
318 * source: 'dbus'
319 * item: 'status'
320 * value: 33
321 * operator: '=='
322 */
323
324 System.out.println("roadbook:su:" + line);
325
326 String name_str = line.split(":", 2)[0].replace(" ", "");
327 String value_str = line.split(":", 2)[1].replace(" ", "");
328
329 if (name_str.equalsIgnoreCase("source"))
330 {
331 success_source = value_str;
332 }
333 else if (name_str.equalsIgnoreCase("item"))
334 {
335 success_item = value_str;
336 }
337 else if (name_str.equalsIgnoreCase("value"))
338 {
339 success_value = value_str;
340 }
341 else if (name_str.equalsIgnoreCase("operator"))
342 {
343 success_operator = value_str;
344 }
345 }
346 else
347 {
348 // read lat,lon
349 String name_str = line.split(":", 2)[0];
350 String value_str = line.split(":", 2)[1];
351 double lat = 0.0;
352 double lon = 0.0;
353 double heading = 0.0;
354
355 if (name_str.contains("lat"))
356 {
357 lat = Double.parseDouble(value_str);
358 if (mode.equals("from"))
359 {
360 lat_pos = lat;
361 }
362 else if (mode.equals("to"))
363 {
364 lat_dst = lat;
365 }
366 }
367 else if (name_str.contains("lng"))
368 {
369 lon = Double.parseDouble(value_str);
370 if (mode.equals("from"))
371 {
372 lon_pos = lon;
373 }
374 else if (mode.equals("to"))
375 {
376 lon_dst = lon;
377 }
378 }
379 else if (name_str.contains("heading"))
380 {
381 heading = Double.parseDouble(value_str);
382 if (mode.equals("from"))
383 {
384 heading_pos = heading;
385 }
386 }
387 }
388 }
389 catch (Exception e2)
390 {
391 System.out.println("_DREX_:001" + e2.getMessage());
392 }
393 }
394 }
395
396 DR_clear_route();
397 Thread.sleep(1000);
398
399 try
400 {
401 int jj = 0;
402 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
403 {
404 jj++;
405 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
406 // wait for old route to be cleared
407 Thread.sleep(1000);
408 }
409 }
410 catch (Exception e)
411 {
412 e.printStackTrace();
413 }
414
415 // DR_clear_route();
416 // Thread.sleep(3000);
417
418 Bundle extras = new Bundle();
419 System.out.println("ZANaviDebugReceiver:" + "set_position" + lat_pos + "," + lon_pos + "," + "0.0" + "," + heading_pos);
420 extras.putString("set_position", "" + lat_pos + "," + lon_pos + "," + "0.0" + "," + heading_pos);
421 DR_set_position("set_position", extras, true);
422 Thread.sleep(2500);
423 //xy//DR_set_position("set_position", extras, true);
424 //xy//Thread.sleep(3200);
425
426 extras = new Bundle();
427 System.out.println("ZANaviDebugReceiver:" + "add_destination" + lat_dst + "," + lon_dst);
428 extras.putString("add_destination", "" + lat_dst + "," + lon_dst);
429 DR_add_destination("add_destination", extras);
430 Thread.sleep(2000);
431
432 flag_route_ready = false;
433
434 // Thread.sleep(1200);
435 // Navit.draw_map();
436
437 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
438
439 final Thread debug_zoom_to_route_001 = new Thread()
440 {
441 int wait = 1;
442 int count = 0;
443 int max_count = 380; // seconds
444 int first_status = -999;
445 int status_wrong = 0;
446
447 @Override
448 public void run()
449 {
450 while (wait == 1)
451 {
452 try
453 {
454 System.out.println("XXXX:#" + count + ":rstatus=" + NavitGraphics.navit_route_status);
455
456 if (first_status == -999)
457 {
458 first_status = NavitGraphics.navit_route_status;
459 }
460
461 if ((first_status == -999) || (first_status == 17) || (first_status == 33))
462 {
463 if (count < 30)
464 {
465 // wait some more! status is wrong it seems!
466 status_wrong = 1;
467 }
468 else
469 {
470 status_wrong = 0;
471 }
472 }
473
474 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
475
476 if (((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) && (status_wrong == 0))
477 {
478 System.out.println("XXXX:--:001");
479
480 // Navit.static_show_route_graph(4);
481
482 Navit.zoom_to_route();
483 Thread.sleep(2000);
484 Navit.zoom_to_route();
485 Thread.sleep(15000);
486 //xy//Navit.draw_map();
487 //xy//Thread.sleep(15000);
488
489 System.out.println("XXXX:--:002");
490
491 File f = new File(file_name_global);
492 File d2 = new File(f.getParent() + "/" + date + "/");
493 d2.mkdirs();
494
495 System.out.println("XXXX:--:003");
496
497 // save route to gpx file
498 DR_save_route_to_gpx_file_with_name(f.getParent() + "/" + date + "/" + f.getName() + ".gpx");
499
500 System.out.println("XXXX:--:004");
501
502 wait = 0;
503 }
504 else
505 {
506 System.out.println("XXXX:--:005");
507
508 wait = 1;
509 }
510
511 if (count > 0)
512 {
513 System.out.println("XXXX:--:006");
514
515 //if (NavitGraphics.navit_route_status == 1)
516 if (NavitGraphics.navit_route_status == 999199) // disable !!
517 {
518 System.out.println("XXXX:--:007");
519 wait = 0;
520 count = max_count;
521 }
522 else if (NavitGraphics.navit_route_status == 3)
523 {
524 System.out.println("XXXX:--:008");
525 wait = 0;
526 count = max_count;
527 }
528 }
529
530 System.out.println("XXXX:--:009");
531
532 count++;
533 if (count > max_count)
534 {
535 System.out.println("XXXX:--:010");
536
537 wait = 0;
538
539 Message msg7 = Navit.Navit_progress_h.obtainMessage();
540 Bundle b7 = new Bundle();
541 msg7.what = 2; // long Toast message
542 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
543 msg7.setData(b7);
544 Navit.Navit_progress_h.sendMessage(msg7);
545 }
546 else
547 {
548 System.out.println("XXXX:--:011");
549
550 Thread.sleep(1000);
551 }
552 }
553 catch (Exception e)
554 {
555 System.out.println("XXXX:--:012");
556
557 System.out.println("_DREX_:002" + Navit.stacktrace_to_string(e));
558 }
559 }
560
561 System.out.println("XXXX:--:013");
562
563 System.out.println("XXXX:rstatus[FIN]=" + NavitGraphics.navit_route_status);
564
565 try
566 {
567
568 if (NavitGraphics.navit_route_status == 3)
569 {
570 // route blocked / no route found
571 DR_clear_route();
572 Thread.sleep(1000);
573 System.out.println("XXXX:route blocked");
574 }
575 else if (NavitGraphics.navit_route_status == 1)
576 {
577 // still calculating route
578 DR_clear_route();
579 Thread.sleep(1000);
580 System.out.println("XXXX:still calculating route");
581 }
582 else
583 {
584 // save map screenshot
585 File f = new File(file_name_global);
586 // System.out.println("NNNNN=" + f.getParent() + "/" + date + "/" + f.getName());
587 File d2 = new File(f.getParent() + "/" + date + "/");
588 d2.mkdirs();
589 Navit.take_map_screenshot(f.getParent() + "/" + date + "/", f.getName());
590 // Navit.take_phone_screenshot(Navit.Global_Navit_Object, f.getParent() + "/" + date + "/", f.getName() + "_full");
591
592 // save roadbook
593 String[] separated = NavitGraphics.GetRoadBookItems(9990001);
594
595 if (separated == null)
596 {
597 System.out.println("XXXX:Roadbook try #2");
598
599 try
600 {
601 Thread.sleep(3000);
602 }
603 catch (InterruptedException e)
604 {
605 }
606 separated = NavitGraphics.GetRoadBookItems(9990001);
607
608 if (separated == null)
609 {
610 System.out.println("XXXX:Roadbook try #3");
611
612 try
613 {
614 Bundle extras77 = new Bundle();
615 System.out.println("ZANaviDebugReceiver:77:" + "set_position" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0");
616 extras77.putString("set_position", "" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0");
617 DR_set_position("set_position", extras77, true);
618 Thread.sleep(1000);
619 }
620 catch (InterruptedException e)
621 {
622 }
623
624 try
625 {
626 Thread.sleep(6000);
627 }
628 catch (InterruptedException e)
629 {
630 }
631 separated = NavitGraphics.GetRoadBookItems(9990001);
632
633 if (separated == null)
634 {
635 separated = new String[4];
636 separated[0] = "broken";
637 separated[1] = "broken";
638 separated[2] = "broken";
639 separated[3] = "broken";
640 }
641 }
642 }
643
644 System.out.println("XXXX:Roadbook(1)=" + separated);
645 if (separated != null)
646 {
647 try
648 {
649 System.out.println("XXXX:Roadbook(2)=" + Arrays.toString(separated));
650 }
651 catch (Exception e)
652 {
653 }
654 }
655
656 if ((separated != null) && (separated.length < 3))
657 {
658 System.out.println("_DRxx_:018" + "Roadbook items < 3 !!");
659 }
660
661 int jk = 0;
662 if (separated != null)
663 {
664 if (separated.length > 2)
665 {
666 FileOutputStream outf = null;
667 try
668 {
669 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
670 }
671 catch (Exception ef)
672 {
673 //System.out.println("EE002:" + ef.getMessage());
674 System.out.println("_DREX_:003" + ef.getMessage());
675 }
676
677 OutputStreamWriter out = null;
678 try
679 {
680 out = new OutputStreamWriter(outf);
681 }
682 catch (Exception e)
683 {
684 // System.out.println("EE003:" + e.getMessage());
685 System.out.println("_DREX_:004" + e.getMessage());
686 }
687
688 //System.out.println("Roadbook:length=" + (separated.length - 2));
689 try
690 {
691 out.write("Roadbook:length=" + (separated.length - 2) + "\n");
692 }
693 catch (Exception e)
694 {
695 //System.out.println("EE004:" + e.getMessage());
696 System.out.println("_DREX_:005" + e.getMessage());
697 }
698
699 for (jk = 0; jk < separated.length; jk++)
700 {
701 System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
702 if (jk > 2)
703 {
704 String[] values = new String[5];
705 String[] values2 = separated[jk].split(":");
706 values[0] = values2[0];
707 values[1] = values2[1];
708 values[2] = values2[2];
709 values[3] = values2[3];
710 try
711 {
712 values[4] = values2[4];
713 }
714 catch (Exception ee)
715 {
716 values[4] = "";
717 System.out.println("_DREX_:006" + ee.getMessage());
718 }
719 // 0 string:distance short form
720 // 1 lat
721 // 2 lon
722 // 3 icon name
723 // 4 text
724
725 // if (values[3].compareTo("nav_waypoint") == 0)
726 // {
727 // }
728 // else if (values[3].compareTo("nav_destination") == 0)
729 // {
730 // }
731 // else
732 // {
733 // }
734
735 try
736 {
737 System.out.println("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4]);
738 out.write("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4] + "\n");
739 }
740 catch (Exception ee)
741 {
742 System.out.println("_DREX_:007" + ee.getMessage());
743 }
744 }
745 else if (jk == 1)
746 {
747 String[] values_local = separated[jk].split(":");
748 try
749 {
750 local_meters_value = Integer.parseInt(values_local[1]);
751 }
752 catch (Exception e)
753 {
754 local_meters_value = 0;
755 System.out.println("_DREX_:008" + Navit.stacktrace_to_string(e));
756 }
757
758 System.out.println("Roadbook:distance=" + local_meters_value);
759 try
760 {
761 out.write("Roadbook:distance [m]=" + local_meters_value + "\n");
762 }
763 catch (Exception e)
764 {
765 System.out.println("_DREX_:009" + e.getMessage());
766 }
767 }
768 else if (jk == 2)
769 {
770 System.out.println("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + "");
771 try
772 {
773 out.write("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + "" + "\n");
774 }
775 catch (Exception e)
776 {
777 System.out.println("_DREX_:010" + e.getMessage());
778 }
779 }
780 }
781
782 try
783 {
784 out.write("URL1:" + "http://map.project-osrm.org/?z=10&loc=" + lat_pos + "%2C" + lon_pos + "&loc=" + lat_dst + "%2C" + lon_dst + "&hl=en&alt=0\n");
785 out.write("URL2:" + "https://graphhopper.com/maps/?point=" + lat_pos + "%2C" + lon_pos + "&point=" + lat_dst + "%2C" + lon_dst + "\n");
786 out.write("URL3:" + "http://www.google.com/maps/dir/" + lat_pos + "," + lon_pos + "/" + lat_dst + "," + lon_dst + "\n");
787 out.write("URL4:" + "http://www.openstreetmap.org/directions?engine=osrm_car&route=" + lat_pos + "%2C" + lon_pos + "%3B" + lat_dst + "%2C" + lon_dst + "\n");
788 }
789 catch (Exception e)
790 {
791 System.out.println("_DREX_:046" + e.getMessage());
792 }
793
794 try
795 {
796 out.flush();
797 out.close();
798 outf.flush();
799 outf.close();
800 }
801 catch (Exception e)
802 {
803 System.out.println("_DREX_:016" + e.getMessage());
804 }
805 }
806 }
807 // else
808 // {
809 // System.out.println("_DRxx_:017" + "Roadbook items = NULL !!");
810 // }
811
812 // calculate success criterion ----------------------
813 // calculate success criterion ----------------------
814
815 result_code = -1;
816
817 if ((!success_operator.equals("")) && (!success_value.equals("")))
818 {
819 System.out.println("roadbook:so=" + success_source);
820 System.out.println("roadbook:it=" + success_item);
821 System.out.println("roadbook:sv=" + success_value);
822
823 if (success_source.equalsIgnoreCase("'dbus'"))
824 {
825 if (success_item.equalsIgnoreCase("'status'"))
826 {
827 int s = NavitGraphics.navit_route_status;
828 int v = Integer.parseInt(success_value);
829
830 if ((success_operator.contains(">")) || ((success_operator.contains("<"))))
831 {
832 if (s == 17)
833 {
834 s = 33;
835 }
836 }
837 else
838 {
839 if (v == 33)
840 {
841 v = 17;
842 if (s == 33)
843 {
844 s = 17;
845 }
846 }
847 else if (v == 17)
848 {
849 if (s == 33)
850 {
851 s = 17;
852 }
853 }
854 }
855 result_code = success_value_compare(s, v);
856
857 System.out.println("roadbook:003:" + s + " " + v);
858 }
859 else if (success_item.equalsIgnoreCase("'distance'"))
860 {
861 int s = local_meters_value;
862 int v = Integer.parseInt(success_value);
863 result_code = success_value_compare(s, v);
864
865 System.out.println("roadbook:001:" + s + " " + v);
866 }
867 }
868 else if (success_source.equalsIgnoreCase("'gpx'"))
869 {
870 if (success_item.equalsIgnoreCase("'nodes'"))
871 {
872 int s = -99;
873 s = (separated.length - 2);
874 int v = Integer.parseInt(success_value);
875 result_code = success_value_compare(s, v);
876
877 System.out.println("roadbook:002:" + s + " " + v);
878 }
879 else if (success_item.startsWith("'nav"))
880 {
881 String nav_num_str = success_item.replace("'nav", "").replace("'", "");
882 int nav_num = Integer.parseInt(nav_num_str);
883
884 if (separated.length > (nav_num + 2))
885 {
886 // ok we have enough entries in roadbook
887
888 String[] values = new String[5];
889 String[] values2 = separated[nav_num + 2].split(":");
890 values[0] = values2[0];
891 values[1] = values2[1];
892 values[2] = values2[2];
893 values[3] = values2[3];
894 try
895 {
896 values[4] = values2[4];
897 }
898 catch (Exception ee)
899 {
900 values[4] = "";
901 System.out.println("_DREX_:006entries" + ee.getMessage());
902 }
903 // 0 string:distance short form
904 // 1 lat
905 // 2 lon
906 // 3 icon name
907 // 4 text
908
909 if (values[3].equalsIgnoreCase(success_value))
910 {
911 result_code = 0;
912 }
913 else
914 {
915 result_code = -1;
916 }
917 }
918 else
919 {
920 // not enough entries in roadbook --> fail
921 result_code = -1;
922 }
923
924 System.out.println("roadbook:002:" + success_item + " " + success_value);
925 }
926
927 }
928 }
929
930 System.out.println("++--------++ roadbook:RES=" + result_code);
931
932 if (result_code == 0)
933 {
934 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
935 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
936 File f2 = new File(orig);
937 File f2_to = new File(rename_to);
938 f2.renameTo(f2_to);
939
940 yaml_err--;
941 }
942 else
943 {
944 }
945
946 // calculate success criterion ----------------------
947 // calculate success criterion ----------------------
948
949 }
950
951 }
952 catch (Exception ebig)
953 {
954 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
955 }
956
957 flag_route_ready = true;
958 }
959 };
960 debug_zoom_to_route_001.start();
961 debug_zoom_to_route_001.join();
962 Thread.sleep(500);
963
964 is_replaying = false;
965 NavitGraphics.NavitAOverlay_s.postInvalidate();
966 br.close();
967 }
968 }
969 catch (Exception e)
970 {
971 System.out.println("_DREX_:011" + e.getMessage());
972 is_replaying = false;
973 NavitGraphics.NavitAOverlay_s.postInvalidate();
974 }
975 }
976
977 static void DR_replay_yaml_file_search_n(String filename, final String date)
978 {
979
980 file_name_global = filename;
981
982 yaml_err++; // incr. error count (on success later -> decrease it again)
983
984 try
985 {
986 if ((filename != null) && (!filename.equals("")))
987 {
988 BufferedReader br = null;
989 br = new BufferedReader(new FileReader(filename));
990
991 is_replaying = true;
992 NavitGraphics.NavitAOverlay_s.postInvalidate();
993
994 disable_normal_location();
995
996 DR_clear_route();
997 Thread.sleep(1000);
998
999 String str_str = "";
1000 String city_str = "";
1001 String hn_str = "";
1002
1003 String mode = "-";
1004 String line = "";
1005 while ((line = br.readLine()) != null)
1006 {
1007 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1008 {
1009 mode = "type";
1010 }
1011 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1012 {
1013 mode = "input";
1014 }
1015 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1016 {
1017 mode = "success";
1018 }
1019 else if ((line.length() > 2) && (!line.startsWith("#")))
1020 {
1021 try
1022 {
1023 if (mode == "success")
1024 {
1025 String name_str = line.split(":", 2)[0].replace(" ", "");
1026 String value_str = line.split(":", 2)[1].replace(" ", "");
1027
1028 if (name_str.equalsIgnoreCase("item"))
1029 {
1030 success_item = value_str;
1031 }
1032 else if (name_str.equalsIgnoreCase("value"))
1033 {
1034 success_value = value_str;
1035 }
1036 else if (name_str.equalsIgnoreCase("operator"))
1037 {
1038 success_operator = value_str;
1039 }
1040 }
1041 else if (mode == "type")
1042 {
1043 // do nothing
1044 }
1045 else
1046 {
1047 String name_str = line.split(":", 2)[0];
1048 String value_str = line.split(":", 2)[1];
1049
1050 if (name_str.contains("street"))
1051 {
1052 str_str = value_str;
1053 }
1054 else if (name_str.contains("city"))
1055 {
1056 city_str = value_str;
1057 }
1058 else if (name_str.contains("housenumber"))
1059 {
1060 hn_str = value_str;
1061 }
1062 }
1063 }
1064 catch (Exception e2)
1065 {
1066 System.out.println("_DREX_:001" + e2.getMessage());
1067 }
1068 }
1069 }
1070
1071 try
1072 {
1073 int jj = 0;
1074 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1075 {
1076 jj++;
1077 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1078 // wait for old route to be cleared
1079 Thread.sleep(1000);
1080 }
1081 }
1082 catch (Exception e)
1083 {
1084 e.printStackTrace();
1085 }
1086
1087 final String str_str_f = str_str;
1088 final String city_str_f = city_str;
1089 final String hn_str_f = hn_str;
1090
1091 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1092
1093 final Thread search_n_002 = new Thread()
1094 {
1095 int wait = 1;
1096
1097 @Override
1098 public void run()
1099 {
1100 while (wait == 1)
1101 {
1102 try
1103 {
1104 // -------- ST N --------
1105 // -------- ST N --------
1106 // -------- ST N --------
1107
1108 // clear results
1109 Navit.NavitAddressResultList_foundItems.clear();
1110 Navit.Navit_Address_Result_double_index.clear();
1111 Navit.NavitSearchresultBarIndex = -1;
1112 Navit.NavitSearchresultBar_title = "";
1113 Navit.NavitSearchresultBar_text = "";
1114 Navit.search_results_towns = 0;
1115 Navit.search_results_streets = 0;
1116 Navit.search_results_streets_hn = 0;
1117 Navit.search_results_poi = 0;
1118
1119 Navit.search_list_ready = false;
1120
1121 final Thread tttt2 = new Thread()
1122 {
1123 @Override
1124 public void run()
1125 {
1126 System.out.println("search test 001");
1127 Navit.use_index_search = false;
1128 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, false, true, true);
1129 }
1130 };
1131 tttt2.start();
1132 System.out.println("search test 002");
1133 Thread.sleep(2000);
1134 System.out.println("search test 003");
1135
1136 // -- wait for search result --
1137 int c4 = 0;
1138 boolean no_result = false;
1139 while (Navit.search_ready == false)
1140 {
1141 System.out.println("search test 004:" + c4);
1142 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1143
1144 Thread.sleep(500);
1145 c4++;
1146
1147 if (c4 > (2 * 60) * 40)
1148 {
1149 System.out.println("search test 004a");
1150 Navit.search_ready = true;
1151 no_result = true;
1152 }
1153 }
1154 // -- wait for search result --
1155
1156 Thread.sleep(1500);
1157
1158 System.out.println("search test 005");
1159 c4 = 0;
1160 if (no_result == false)
1161 {
1162 while (Navit.search_list_ready == false)
1163 {
1164 System.out.println("search test 004b:" + c4);
1165 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1166
1167 Thread.sleep(500);
1168 c4++;
1169
1170 if (c4 > (2 * 60) * 2)
1171 {
1172 System.out.println("search test 004ab");
1173 break;
1174 }
1175 }
1176 }
1177 System.out.println("search test 006");
1178
1179 Thread.sleep(5000);
1180
1181 // save screenshot
1182 System.out.println("SCREENSHOT 001");
1183 try
1184 {
1185 File f = new File(file_name_global);
1186 File d2 = new File(f.getParent() + "/" + date + "/");
1187 d2.mkdirs();
1188 Navit.take_phone_screenshot(NavitAddressResultListActivity.NavitAddressResultListActivity_s, f.getParent() + "/" + date + "/", f.getName());
1189 }
1190 catch (Exception ee4)
1191 {
1192 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1193 ee4.printStackTrace();
1194 }
1195 System.out.println("SCREENSHOT 002");
1196
1197 try
1198 {
1199 NavitAddressResultListActivity.force_done();
1200 }
1201 catch (Exception ee4)
1202 {
1203 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1204 ee4.printStackTrace();
1205 }
1206
1207 System.out.println("SCREENSHOT 003");
1208
1209 wait = 0;
1210 // -------- ST N --------
1211 // -------- ST N --------
1212 // -------- ST N --------
1213
1214 FileOutputStream outf = null;
1215 try
1216 {
1217 File f = new File(file_name_global);
1218 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
1219 }
1220 catch (Exception ef)
1221 {
1222 //System.out.println("EE002:" + ef.getMessage());
1223 System.out.println("_DREX_:003" + ef.getMessage());
1224 }
1225
1226 OutputStreamWriter out = null;
1227 try
1228 {
1229 out = new OutputStreamWriter(outf);
1230 }
1231 catch (Exception e)
1232 {
1233 // System.out.println("EE003:" + e.getMessage());
1234 System.out.println("_DREX_:004" + e.getMessage());
1235 }
1236
1237 //System.out.println("Roadbook:length=" + (separated.length - 2));
1238 try
1239 {
1240 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
1241 }
1242 catch (Exception e)
1243 {
1244 //System.out.println("EE004:" + e.getMessage());
1245 System.out.println("_DREX_:005" + e.getMessage());
1246 }
1247
1248 try
1249 {
1250 int i = 0;
1251 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
1252 {
1253 out.write("result:" + i + ":" + Navit.NavitAddressResultList_foundItems.get(i).result_type + ":" + Navit.NavitAddressResultList_foundItems.get(i).lat + ":" + Navit.NavitAddressResultList_foundItems.get(i).lon + ":" + Navit.NavitAddressResultList_foundItems.get(i).addr + "\n");
1254 }
1255 }
1256 catch (Exception e)
1257 {
1258 //System.out.println("EE004:" + e.getMessage());
1259 System.out.println("_DREX_:005a" + e.getMessage());
1260 }
1261
1262 try
1263 {
1264 out.write("URL1:" + "http://nominatim.openstreetmap.org/search.php?q=" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1265 out.write("URL2:" + "https://www.google.at/maps/place/" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1266 // out.write("URL3:" + "about:\n");
1267 }
1268 catch (Exception e)
1269 {
1270 System.out.println("_DREX_:046" + e.getMessage());
1271 }
1272
1273 try
1274 {
1275 out.flush();
1276 out.close();
1277 outf.flush();
1278 outf.close();
1279 }
1280 catch (Exception e)
1281 {
1282 System.out.println("_DREX_:016" + e.getMessage());
1283 }
1284
1285 // calculate success criterion ----------------------
1286 // calculate success criterion ----------------------
1287
1288 result_code = -1;
1289
1290 if ((!success_operator.equals("")) && (!success_value.equals("")))
1291 {
1292 // System.out.println("search:so=" + success_source);
1293 System.out.println("search:it=" + success_item);
1294 System.out.println("search:sv=" + success_value);
1295
1296 if (success_item.equalsIgnoreCase("'resultcount'"))
1297 {
1298 try
1299 {
1300 int s = Navit.NavitAddressResultList_foundItems.size();
1301 int v = Integer.parseInt(success_value);
1302 result_code = success_value_compare(s, v);
1303 }
1304 catch (Exception e)
1305 {
1306 result_code = -1;
1307 }
1308 }
1309 }
1310
1311 // dummy for circleCI
1312 File f3 = new File(file_name_global);
1313 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1314 // dummy for circleCI
1315
1316 if (result_code == 0)
1317 {
1318 File f = new File(file_name_global);
1319 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
1320 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
1321 File f2 = new File(orig);
1322 File f2_to = new File(rename_to);
1323 f2.renameTo(f2_to);
1324
1325 yaml_err--;
1326 }
1327 else
1328 {
1329 }
1330
1331 // calculate success criterion ----------------------
1332 // calculate success criterion ----------------------
1333
1334 }
1335 catch (Exception ebig)
1336 {
1337 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1338 }
1339 }
1340 }
1341 };
1342 search_n_002.start();
1343 search_n_002.join();
1344 Thread.sleep(500);
1345
1346 is_replaying = false;
1347 NavitGraphics.NavitAOverlay_s.postInvalidate();
1348 br.close();
1349 }
1350 }
1351 catch (Exception e)
1352 {
1353 System.out.println("_DREX_:011" + e.getMessage());
1354 is_replaying = false;
1355 NavitGraphics.NavitAOverlay_s.postInvalidate();
1356 }
1357 }
1358
1359 static void DR_replay_yaml_file_search_i(String filename, final String date)
1360 {
1361
1362 file_name_global = filename;
1363
1364 yaml_err++; // incr. error count (on success later -> decrease it again)
1365
1366 try
1367 {
1368 if ((filename != null) && (!filename.equals("")))
1369 {
1370 BufferedReader br = null;
1371 br = new BufferedReader(new FileReader(filename));
1372
1373 is_replaying = true;
1374 NavitGraphics.NavitAOverlay_s.postInvalidate();
1375
1376 disable_normal_location();
1377
1378 DR_clear_route();
1379 Thread.sleep(1000);
1380
1381 String str_str = "";
1382 String city_str = "";
1383 String hn_str = "";
1384
1385 String mode = "-";
1386 String line = "";
1387 while ((line = br.readLine()) != null)
1388 {
1389 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1390 {
1391 mode = "type";
1392 }
1393 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1394 {
1395 mode = "input";
1396 }
1397 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1398 {
1399 mode = "success";
1400 }
1401 else if ((line.length() > 2) && (!line.startsWith("#")))
1402 {
1403 try
1404 {
1405 if (mode == "success")
1406 {
1407 String name_str = line.split(":", 2)[0].replace(" ", "");
1408 String value_str = line.split(":", 2)[1].replace(" ", "");
1409
1410 if (name_str.equalsIgnoreCase("item"))
1411 {
1412 success_item = value_str;
1413 }
1414 else if (name_str.equalsIgnoreCase("value"))
1415 {
1416 success_value = value_str;
1417 }
1418 else if (name_str.equalsIgnoreCase("operator"))
1419 {
1420 success_operator = value_str;
1421 }
1422 }
1423 else if (mode == "type")
1424 {
1425 // do nothing
1426 }
1427 else
1428 {
1429 String name_str = line.split(":", 2)[0];
1430 String value_str = line.split(":", 2)[1];
1431
1432 if (name_str.contains("street"))
1433 {
1434 str_str = value_str;
1435 }
1436 else if (name_str.contains("city"))
1437 {
1438 city_str = value_str;
1439 }
1440 else if (name_str.contains("housenumber"))
1441 {
1442 hn_str = value_str;
1443 }
1444 }
1445 }
1446 catch (Exception e2)
1447 {
1448 System.out.println("_DREX_:001" + e2.getMessage());
1449 }
1450 }
1451 }
1452
1453 try
1454 {
1455 int jj = 0;
1456 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1457 {
1458 jj++;
1459 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1460 // wait for old route to be cleared
1461 Thread.sleep(1000);
1462 }
1463 }
1464 catch (Exception e)
1465 {
1466 e.printStackTrace();
1467 }
1468
1469 final String str_str_f = str_str;
1470 final String city_str_f = city_str;
1471 final String hn_str_f = hn_str;
1472
1473 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1474
1475 final Thread search_n_001 = new Thread()
1476 {
1477 int wait = 1;
1478
1479 @Override
1480 public void run()
1481 {
1482 while (wait == 1)
1483 {
1484 try
1485 {
1486
1487 // -------- ST I --------
1488 // -------- ST I --------
1489 // -------- ST I --------
1490
1491 // clear results
1492 Navit.NavitAddressResultList_foundItems.clear();
1493 Navit.Navit_Address_Result_double_index.clear();
1494 Navit.NavitSearchresultBarIndex = -1;
1495 Navit.NavitSearchresultBar_title = "";
1496 Navit.NavitSearchresultBar_text = "";
1497 Navit.search_results_towns = 0;
1498 Navit.search_results_streets = 0;
1499 Navit.search_results_streets_hn = 0;
1500 Navit.search_results_poi = 0;
1501
1502 final Thread tttt2 = new Thread()
1503 {
1504 @Override
1505 public void run()
1506 {
1507 System.out.println("search test 001");
1508 Navit.use_index_search = true;
1509 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, true, true, true);
1510 }
1511 };
1512 tttt2.start();
1513 System.out.println("search test 002");
1514 Thread.sleep(2000);
1515 System.out.println("search test 003");
1516
1517 // -- wait for search result --
1518 int c4 = 0;
1519 boolean no_result = false;
1520 Navit.search_list_ready = false;
1521 while (Navit.search_ready == false)
1522 {
1523 System.out.println("search test 004:" + c4);
1524 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1525
1526 Thread.sleep(500);
1527 c4++;
1528
1529 if (c4 > (2 * 60) * 40)
1530 {
1531 System.out.println("search test 004a");
1532 Navit.search_ready = true;
1533 no_result = true;
1534 }
1535 }
1536 // -- wait for search result --
1537
1538 System.out.println("search test 005");
1539
1540 Thread.sleep(6000);
1541
1542 Navit.runOnUI(new Runnable()
1543 {
1544 @Override
1545 public void run()
1546 {
1547 try
1548 {
1549 System.out.println("hide keyboard-1");
1550 // now hide the keyboard
1551 InputMethodManager inputManager = (InputMethodManager) Navit.Global_Navit_Object.getSystemService(Context.INPUT_METHOD_SERVICE);
1552 inputManager.hideSoftInputFromWindow(Navit.Global_Navit_Object.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
1553 inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
1554 System.out.println("hide keyboard-2");
1555 }
1556 catch (Exception e)
1557 {
1558 e.printStackTrace();
1559 System.out.println("hide keyboard-3");
1560 }
1561 }
1562 });
1563
1564 System.out.println("search test 005");
1565 Thread.sleep(1500);
1566
1567 // save screenshot
1568 System.out.println("SCREENSHOT 001");
1569 try
1570 {
1571 File f = new File(file_name_global);
1572 File d2 = new File(f.getParent() + "/" + date + "/");
1573 d2.mkdirs();
1574 Navit.take_phone_screenshot(NavitAddressSearchActivity.NavitAddressSearchActivity_s, f.getParent() + "/" + date + "/", f.getName());
1575 }
1576 catch (Exception ee4)
1577 {
1578 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1579 ee4.printStackTrace();
1580 }
1581 System.out.println("SCREENSHOT 002");
1582
1583 try
1584 {
1585 NavitAddressSearchActivity.force_done();
1586 }
1587 catch (Exception ee4)
1588 {
1589 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1590 ee4.printStackTrace();
1591 }
1592
1593 System.out.println("SCREENSHOT 003");
1594
1595 wait = 0;
1596 // -------- ST I --------
1597 // -------- ST I --------
1598 // -------- ST I --------
1599
1600 FileOutputStream outf = null;
1601 try
1602 {
1603 File f = new File(file_name_global);
1604 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
1605 }
1606 catch (Exception ef)
1607 {
1608 //System.out.println("EE002:" + ef.getMessage());
1609 System.out.println("_DREX_:003" + ef.getMessage());
1610 }
1611
1612 OutputStreamWriter out = null;
1613 try
1614 {
1615 out = new OutputStreamWriter(outf);
1616 }
1617 catch (Exception e)
1618 {
1619 // System.out.println("EE003:" + e.getMessage());
1620 System.out.println("_DREX_:004" + e.getMessage());
1621 }
1622
1623 //System.out.println("Roadbook:length=" + (separated.length - 2));
1624 try
1625 {
1626 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
1627 }
1628 catch (Exception e)
1629 {
1630 //System.out.println("EE004:" + e.getMessage());
1631 System.out.println("_DREX_:005" + e.getMessage());
1632 }
1633
1634 try
1635 {
1636 int i = 0;
1637 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
1638 {
1639 out.write("result:" + i + ":" + Navit.NavitAddressResultList_foundItems.get(i).result_type + ":" + Navit.NavitAddressResultList_foundItems.get(i).lat + ":" + Navit.NavitAddressResultList_foundItems.get(i).lon + ":" + Navit.NavitAddressResultList_foundItems.get(i).addr + "\n");
1640 }
1641 }
1642 catch (Exception e)
1643 {
1644 //System.out.println("EE004:" + e.getMessage());
1645 System.out.println("_DREX_:005a" + e.getMessage());
1646 }
1647
1648 try
1649 {
1650 // http://nominatim.openstreetmap.org/search.php?q=wienerneustadt+blubgasse+99
1651 out.write("URL1:" + "http://nominatim.openstreetmap.org/search.php?q=" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1652 out.write("URL2:" + "https://www.google.at/maps/place/" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1653 // out.write("URL3:" + "\n");
1654 }
1655 catch (Exception e)
1656 {
1657 System.out.println("_DREX_:046" + e.getMessage());
1658 }
1659
1660 try
1661 {
1662 out.flush();
1663 out.close();
1664 outf.flush();
1665 outf.close();
1666 }
1667 catch (Exception e)
1668 {
1669 System.out.println("_DREX_:016" + e.getMessage());
1670 }
1671
1672 // calculate success criterion ----------------------
1673 // calculate success criterion ----------------------
1674
1675 result_code = -1;
1676
1677 if ((!success_operator.equals("")) && (!success_value.equals("")))
1678 {
1679 // System.out.println("search:so=" + success_source);
1680 System.out.println("search:it=" + success_item);
1681 System.out.println("search:sv=" + success_value);
1682
1683 if (success_item.equalsIgnoreCase("'resultcount'"))
1684 {
1685 try
1686 {
1687 int s = Navit.NavitAddressResultList_foundItems.size();
1688 int v = Integer.parseInt(success_value);
1689 result_code = success_value_compare(s, v);
1690 }
1691 catch (Exception e)
1692 {
1693 result_code = -1;
1694 }
1695 }
1696 }
1697
1698 // dummy for circleCI
1699 File f3 = new File(file_name_global);
1700 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1701 // dummy for circleCI
1702
1703 if (result_code == 0)
1704 {
1705 File f = new File(file_name_global);
1706 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
1707 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
1708 File f2 = new File(orig);
1709 File f2_to = new File(rename_to);
1710 f2.renameTo(f2_to);
1711
1712 yaml_err--;
1713 }
1714 else
1715 {
1716 }
1717
1718 // calculate success criterion ----------------------
1719 // calculate success criterion ----------------------
1720
1721 }
1722 catch (Exception ebig)
1723 {
1724 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1725 }
1726 }
1727 }
1728 };
1729 search_n_001.start();
1730 search_n_001.join();
1731 Thread.sleep(500);
1732
1733 is_replaying = false;
1734 NavitGraphics.NavitAOverlay_s.postInvalidate();
1735 br.close();
1736 }
1737 }
1738 catch (Exception e)
1739 {
1740 System.out.println("_DREX_:011" + e.getMessage());
1741 is_replaying = false;
1742 NavitGraphics.NavitAOverlay_s.postInvalidate();
1743 }
1744 }
1745
1746 static int success_value_compare(int s, int v)
1747 {
1748 if (success_operator.equalsIgnoreCase("'=='"))
1749 {
1750 if (s == v)
1751 {
1752 return 0;
1753 }
1754 }
1755 else if (success_operator.equalsIgnoreCase("'<>'"))
1756 {
1757 if (s != v)
1758 {
1759 return 0;
1760 }
1761 }
1762 else if (success_operator.equalsIgnoreCase("'!='"))
1763 {
1764 if (s != v)
1765 {
1766 return 0;
1767 }
1768 }
1769 else if (success_operator.equalsIgnoreCase("'<'"))
1770 {
1771 if (s < v)
1772 {
1773 return 0;
1774 }
1775 }
1776 else if (success_operator.equalsIgnoreCase("'<='"))
1777 {
1778 if (s <= v)
1779 {
1780 return 0;
1781 }
1782 }
1783 else if (success_operator.equalsIgnoreCase("'=<'"))
1784 {
1785 if (s <= v)
1786 {
1787 return 0;
1788 }
1789 }
1790 else if (success_operator.equalsIgnoreCase("'>'"))
1791 {
1792 if (s > v)
1793 {
1794 return 0;
1795 }
1796 }
1797 else if (success_operator.equalsIgnoreCase("'>='"))
1798 {
1799 if (s >= v)
1800 {
1801 return 0;
1802 }
1803 }
1804 else if (success_operator.equalsIgnoreCase("'=>'"))
1805 {
1806 if (s >= v)
1807 {
1808 return 0;
1809 }
1810 }
1811
1812 return -1;
1813 }
1814
1815 static void DR_run_all_yaml_tests()
1816 {
1817 String yaml_dir = Navit.NAVIT_DATA_DEBUG_DIR + "../yamltests/";
1818 String duration_string = "";
1819
1820 try
1821 {
1822 File dir = new File(yaml_dir);
1823 try
1824 {
1825 dir.mkdirs();
1826 }
1827 catch (Exception e2)
1828 {
1829 // System.out.println("XXXX:E01" + e2.getMessage());
1830 System.out.println("_DREX_:012" + e2.getMessage());
1831 }
1832
1833 Navit.static_show_route_graph(4);
1834
1835 String date_str = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1836
1837 FilenameFilter textFilter = new FilenameFilter()
1838 {
1839 public boolean accept(File dir, String name)
1840 {
1841 String lowercaseName = name.toLowerCase(Locale.GERMAN);
1842 if (lowercaseName.endsWith(".yaml"))
1843 {
1844 return true;
1845 }
1846 else
1847 {
1848 return false;
1849 }
1850 }
1851 };
1852
1853 System.out.println("XXXX:1:" + dir);
1854
1855 yaml_sum = 0;
1856 yaml_err = 0;
1857 BufferedReader br = null;
1858 String line2 = "";
1859
1860 File[] directoryListing = dir.listFiles(textFilter);
1861 if (directoryListing != null)
1862 {
1863 for (File yamlfile : directoryListing)
1864 {
1865 yaml_sum++;
1866
1867 final Thread temp_work_thread = new Thread()
1868 {
1869 @Override
1870 public void run()
1871 {
1872 try
1873 {
1874 //if (Navit.CIDEBUG > 0) // automatic debug run
1875 //{
1876 // Navit.show_geo_on_screen_no_draw(0, 0);
1877 // Thread.sleep(200);
1878 // Navit.set_zoom_level_no_draw((int) Math.pow(2, 5)); // zoom level: (18 - 5) = 13
1879 // Thread.sleep(200);
1880 //}
1881 //else
1882 //{
1883 Navit.show_geo_on_screen_no_draw(0, 0);
1884 Thread.sleep(150);
1885 Navit.set_zoom_level_no_draw((int) Math.pow(2, 17));
1886 Thread.sleep(120);
1887 //}
1888 }
1889 catch (Exception e2)
1890 {
1891 System.out.println("_DREX_:013" + e2.getMessage());
1892 e2.printStackTrace();
1893 }
1894 }
1895 };
1896 temp_work_thread.start();
1897 temp_work_thread.join();
1898
1899 System.out.println("XXXX:2:1:" + "");
1900 System.out.println("XXXX:2:2:" + "");
1901 System.out.println("XXXX:2:3:" + "======= START =======");
1902 long startTime = System.currentTimeMillis();
1903 System.out.println("XXXX:2:4:" + yamlfile.getAbsolutePath());
1904
1905 br = null;
1906 line2 = "";
1907 try
1908 {
1909 br = new BufferedReader(new FileReader(yamlfile.getAbsolutePath()));
1910 line2 = br.readLine();
1911 }
1912 catch (Exception e66)
1913 {
1914 }
1915
1916 if ((line2.length() >= "type:".length()) && (line2.equals("type: 'NS'")))
1917 {
1918 DR_replay_yaml_file_search_n(yamlfile.getAbsolutePath(), date_str);
1919 }
1920 else if ((line2.length() >= "type:".length()) && (line2.equals("type: 'IS'")))
1921 {
1922 DR_replay_yaml_file_search_i(yamlfile.getAbsolutePath(), date_str);
1923 }
1924 else
1925 {
1926 DR_replay_gps_file(yamlfile.getAbsolutePath(), date_str);
1927 }
1928
1929 System.out.println("XXXX:2:5:" + yamlfile.getAbsolutePath());
1930 float difference = (float) (System.currentTimeMillis() - startTime);
1931 duration_string = duration_string + yamlfile.getName() + ":" + (difference / 1000.0f) + "\n";
1932 System.out.println("XXXX:2:6:" + "======= END ======= duration: " + (difference / 1000.0f) + " secs.");
1933 System.out.println("XXXX:2:7:" + "");
1934 System.out.println("XXXX:2:8:" + "");
1935
1936 //xy//Thread.sleep(1500);
1937
1938 }
1939 }
1940 }
1941 catch (Exception e)
1942 {
1943 // System.out.println("XXXX:E02" + e.getMessage());
1944 System.out.println("_DREX_:019" + e.getMessage());
1945 }
1946
1947 try
1948 {
1949 FileOutputStream outf = null;
1950 OutputStreamWriter out = null;
1951 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_DURATION_XX_XX_.txt");
1952 out = new OutputStreamWriter(outf);
1953 out.write(duration_string);
1954 out.flush();
1955 out.close();
1956 }
1957 catch (Exception ef2)
1958 {
1959 System.out.println("_DREX_:034" + ef2.getMessage());
1960 }
1961
1962 try
1963 {
1964 FileOutputStream outf = null;
1965 OutputStreamWriter out = null;
1966 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_SUMMARY_XX_XX_.txt");
1967 out = new OutputStreamWriter(outf);
1968 out.write("tests:" + yaml_sum + "\n");
1969 out.write("errors:" + yaml_err + "\n");
1970 if (yaml_err > 0)
1971 {
1972 out.write("RES:" + "ERR" + "\n");
1973 }
1974 else
1975 {
1976 out.write("RES:" + "OK" + "\n");
1977 }
1978 out.flush();
1979 out.close();
1980 }
1981 catch (Exception ef2)
1982 {
1983 System.out.println("_DREX_:014" + ef2.getMessage());
1984 // System.out.println("EE00SUM:" + ef2.getMessage());
1985 }
1986
1987 DR_clear_route();
1988
1989 // restore normal state ----------------------
1990 Navit.static_show_route_graph(3);
1991 enable_normal_location();
1992 // restore normal state ----------------------
1993 }
1994
1995 static void DR_replay_gps_file(String filename, String date_str)
1996 {
1997
1998 System.out.println("ZANaviDebugReceiver:" + "Enter!!");
1999
2000 stop_me = false;
2001 dont_save_loc = true;
2002
2003 try
2004 {
2005 if ((filename != null) && (!filename.equals("")))
2006 {
2007
2008 if (filename.endsWith("yaml"))
2009 {
2010 DR_replay_yaml_file(filename, date_str);
2011 return;
2012 }
2013
2014 BufferedReader br = null;
2015 br = new BufferedReader(new FileReader(filename));
2016
2017 Bundle extras2;
2018
2019 String line = "";
2020 String[] line_parts;
2021
2022 skip_count = skip;
2023 is_replaying = true;
2024 NavitGraphics.NavitAOverlay_s.postInvalidate();
2025
2026 long line_number = 0;
2027
2028 disable_normal_location();
2029
2030 while ((line = br.readLine()) != null)
2031 {
2032 //if (line.length() > 1)
2033 //{
2034 // System.out.println("ZANaviDebugReceiver:" + "line=" + line);
2035 //}
2036
2037 line_number++;
2038
2039 if (stop_me == true)
2040 {
2041 try
2042 {
2043 br.close();
2044 }
2045 catch (Exception ce)
2046 {
2047 ce.printStackTrace();
2048 }
2049
2050 is_replaying = false;
2051 NavitGraphics.NavitAOverlay_s.postInvalidate();
2052 return;
2053 }
2054
2055 if ((rewind_count > 0) && (skip_count == skip))
2056 {
2057 try
2058 {
2059 // seek to start of file and skip lines
2060 br.close();
2061 br = new BufferedReader(new FileReader(filename));
2062
2063 line_number = line_number - rewind_count;
2064 rewind_count = 0;
2065 int l_new = 0;
2066
2067 while (line_number > 0)
2068 {
2069 // just skip lines
2070 line = br.readLine();
2071 // System.out.println("ZANaviDebugReceiver:" + "skip line:" + line + " l=" + l_new);
2072 line_number--;
2073 l_new++;
2074 }
2075
2076 line_number = l_new;
2077 }
2078 catch (Exception ce)
2079 {
2080 ce.printStackTrace();
2081 }
2082 }
2083
2084 if (line.length() > 3)
2085 {
2086 extras2 = new Bundle();
2087 line_parts = line.split(":", 2);
2088
2089 if (line_parts[0].equals("CLR"))
2090 {
2091 if (skip_count >= skip)
2092 {
2093 DR_clear_route();
2094 Thread.sleep(200);
2095 }
2096 else
2097 {
2098 skip_count++;
2099 }
2100 }
2101 else if (line_parts[0].equals("DST"))
2102 {
2103 if (skip_count >= skip)
2104 {
2105 extras2.putString("add_destination", line_parts[1]);
2106 DR_add_destination("add_destination", extras2);
2107 Thread.sleep(5000); // wait 5 seconds to calc route
2108 }
2109 else
2110 {
2111 skip_count++;
2112 }
2113 }
2114 else if (line_parts[0].equals("POS"))
2115 {
2116 while (Navit.follow_current == Navit.follow_off)
2117 {
2118 try
2119 {
2120 Thread.sleep(600);
2121 }
2122 catch (Exception sl1)
2123 {
2124 }
2125 }
2126
2127 if (skip_count >= skip)
2128 {
2129 extras2.putString("set_position", line_parts[1]);
2130 DR_set_position("set_position", extras2, false);
2131 Thread.sleep(950); // about 1 second between locationpoints
2132 }
2133 else
2134 {
2135 skip_count++;
2136 }
2137 }
2138 else
2139 {
2140 }
2141
2142 }
2143 }
2144
2145 is_replaying = false;
2146 System.out.println("ZANaviDebugReceiver:" + "while loop end");
2147 br.close();
2148 }
2149
2150 }
2151 catch (Exception e)
2152 {
2153 System.out.println("_DREX_:015" + e.getMessage());
2154 e.printStackTrace();
2155 System.out.println("ZANaviDebugReceiver:" + "EX:" + e.getMessage());
2156 }
2157
2158 is_replaying = false;
2159 dont_save_loc = true;
2160
2161 NavitGraphics.NavitAOverlay_s.postInvalidate();
2162
2163 System.out.println("ZANaviDebugReceiver:" + "Leave!!");
2164 }
2165
2166 @Override
2167 public void onReceive(Context context, Intent intent)
2168 {
2169 if (Navit.p.PREF_enable_debug_enable_comm)
2170 {
2171 System.out.println("ZANaviDebugReceiver:" + "enter");
2172 try
2173 {
2174 Bundle extras = intent.getExtras();
2175 // System.out.println("ZANaviDebugReceiver:" + "command " + extras.toString());
2176
2177 if (extras != null)
2178 {
2179 for (String key : extras.keySet())
2180 {
2181 if (key.equals("set_position2"))
2182 {
2183 Object value = extras.get(key);
2184 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
2185 float lat = Float.parseFloat(value2.split(",", 2)[0]);
2186 float lon = Float.parseFloat(value2.split(",", 2)[1]);
2187 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2188
2189 Message msg = new Message();
2190 Bundle b = new Bundle();
2191 b.putInt("Callback", 97);
2192 b.putString("lat", String.valueOf(lat));
2193 b.putString("lon", String.valueOf(lon));
2194 b.putString("q", "POSITION");
2195 msg.setData(b);
2196 NavitGraphics.callback_handler.sendMessage(msg);
2197
2198 break;
2199 }
2200 else if (key.equals("set_pos_and_dest"))
2201 {
2202 Object value = extras.get(key);
2203 String value2 = value.toString().replaceAll("\"", "");
2204 // String route_name = value2.split(" ", 5)[0];
2205 float lat1 = Float.parseFloat(value2.split(" ", 5)[2]);
2206 float lon1 = Float.parseFloat(value2.split(" ", 5)[1]);
2207 float lat2 = Float.parseFloat(value2.split(" ", 5)[4]);
2208 float lon2 = Float.parseFloat(value2.split(" ", 5)[3]);
2209
2210 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2211
2212 DR_clear_route();
2213 Thread.sleep(200);
2214 extras = new Bundle();
2215 extras.putString("set_position", "" + lat1 + "," + lon1 + "," + "0.0" + "," + "0");
2216 DR_set_position("set_position", extras, true);
2217 Thread.sleep(1000);
2218 extras = new Bundle();
2219 extras.putString("add_destination", "" + lat2 + "," + lon2);
2220 DR_add_destination("add_destination", extras);
2221
2222 final Thread debug_zoom_to_route_001a = new Thread()
2223 {
2224 int wait = 1;
2225 int count = 0;
2226 int max_count = 60;
2227
2228 @Override
2229 public void run()
2230 {
2231 while (wait == 1)
2232 {
2233 try
2234 {
2235 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
2236 {
2237 // zoom to route
2238 Message msg = new Message();
2239 Bundle b = new Bundle();
2240 b.putInt("Callback", 17);
2241 msg.setData(b);
2242 NavitGraphics.callback_handler.sendMessage(msg);
2243
2244 Navit.set_map_position_to_screen_center();
2245
2246 // save route to gpx file
2247 DR_save_route_to_gpx_file();
2248
2249 wait = 0;
2250 }
2251 else
2252 {
2253 wait = 1;
2254 }
2255
2256 count++;
2257 if (count > max_count)
2258 {
2259 wait = 0;
2260
2261 Message msg7 = Navit.Navit_progress_h.obtainMessage();
2262 Bundle b7 = new Bundle();
2263 msg7.what = 2; // long Toast message
2264 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
2265 msg7.setData(b7);
2266 Navit.Navit_progress_h.sendMessage(msg7);
2267 }
2268 else
2269 {
2270 Thread.sleep(400);
2271 }
2272 }
2273 catch (Exception e)
2274 {
2275 }
2276 }
2277 }
2278 };
2279 debug_zoom_to_route_001a.start();
2280
2281 break;
2282 }
2283 else if (key.equals("set_position"))
2284 {
2285 DR_set_position(key, extras, true);
2286 break;
2287 }
2288 else if (key.equals("add_destination"))
2289 {
2290 DR_add_destination(key, extras);
2291
2292 final Thread debug_zoom_to_route_002 = new Thread()
2293 {
2294 int wait = 1;
2295 int count = 0;
2296 int max_count = 60;
2297
2298 @Override
2299 public void run()
2300 {
2301 while (wait == 1)
2302 {
2303 try
2304 {
2305 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
2306 {
2307 // zoom to route
2308 Message msg = new Message();
2309 Bundle b = new Bundle();
2310 b.putInt("Callback", 17);
2311 msg.setData(b);
2312 NavitGraphics.callback_handler.sendMessage(msg);
2313
2314 Navit.set_map_position_to_screen_center();
2315
2316 wait = 0;
2317 }
2318 else
2319 {
2320 wait = 1;
2321 }
2322
2323 count++;
2324 if (count > max_count)
2325 {
2326 wait = 0;
2327 }
2328 else
2329 {
2330 Thread.sleep(400);
2331 }
2332 }
2333 catch (Exception e)
2334 {
2335 }
2336 }
2337 }
2338 };
2339 debug_zoom_to_route_002.start();
2340
2341 break;
2342 }
2343 else if (key.equals("export_route_gpx"))
2344 {
2345 DR_save_route_to_gpx_file();
2346 break;
2347 }
2348 else if (key.equals("clear_route"))
2349 {
2350 DR_clear_route();
2351 break;
2352 }
2353 else if (key.equals("disable_normal_location"))
2354 {
2355 disable_normal_location();
2356 break;
2357 }
2358 else if (key.equals("enable_normal_location"))
2359 {
2360 NavitVehicle.turn_on_fast_provider();
2361 NavitVehicle.turn_on_precise_provider();
2362 NavitVehicle.turn_on_sat_status();
2363 System.out.println("ZANaviDebugReceiver:" + "enable normal location");
2364 break;
2365 }
2366 }
2367 }
2368 }
2369 catch (Exception e)
2370 {
2371 e.printStackTrace();
2372 }
2373 }
2374 }
2375 }

   
Visit the ZANavi Wiki