/[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 51 - (show annotations) (download)
Mon Jul 25 19:29:08 2016 UTC (7 years, 8 months ago) by zoff99
File size: 68022 byte(s)
v2.0.52
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 static double lat_pos = 0.0;
66 static double lon_pos = 0.0;
67 static double lat_dst = 0.0;
68 static double lon_dst = 0.0;
69 static double heading_pos = 0.0;
70
71 /*
72 *
73 * Examples:
74 *
75 * (params: "lat, lon")
76 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_position2 "48.656, 15.6777"
77 *
78 * lat, lon, speed (m/s), direction (degrees)
79 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_position "48.656, 15.6777, 12, -75"
80 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es add_destination "48.656, 15.6777"
81 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es clear_route ""
82 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es disable_normal_location ""
83 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es enable_normal_location ""
84 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es export_route_gpx ""
85 *
86 *
87 * 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"
88 *
89 * -
90 */
91
92 static void enable_normal_location()
93 {
94 Navit.runOnUI(new Runnable()
95 {
96 @Override
97 public void run()
98 {
99 System.out.println("ZANaviDebugReceiver:" + "ENABLE normal location");
100
101 if (Navit.p.PREF_use_fast_provider)
102 {
103 NavitVehicle.turn_on_fast_provider();
104 }
105 else
106 {
107 NavitVehicle.turn_off_fast_provider();
108 }
109
110 // activate gps AFTER 3g-location
111 NavitVehicle.turn_on_precise_provider();
112 }
113 });
114 }
115
116 static void disable_normal_location()
117 {
118 Navit.runOnUI(new Runnable()
119 {
120 @Override
121 public void run()
122 {
123 NavitVehicle.turn_off_all_providers();
124 NavitVehicle.turn_off_sat_status();
125 System.out.println("ZANaviDebugReceiver:" + "disable normal location");
126 }
127 });
128 }
129
130 static void DR_add_destination(String key, Bundle extras)
131 {
132 Object value = extras.get(key);
133 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
134 float lat = Float.parseFloat(value2.split(",", 2)[0]);
135 float lon = Float.parseFloat(value2.split(",", 2)[1]);
136
137 if (NavitGraphics.navit_route_status == 0)
138 {
139 Navit.destination_set();
140
141 Message msg = new Message();
142 Bundle b = new Bundle();
143 b.putInt("Callback", 3);
144 b.putString("lat", String.valueOf(lat));
145 b.putString("lon", String.valueOf(lon));
146 b.putString("q", "DEST 001");
147 msg.setData(b);
148 NavitGraphics.callback_handler.sendMessage(msg);
149 }
150 else
151 {
152 Message msg = new Message();
153 Bundle b = new Bundle();
154 b.putInt("Callback", 48);
155 b.putString("lat", String.valueOf(lat));
156 b.putString("lon", String.valueOf(lon));
157 b.putString("q", "DEST");
158 msg.setData(b);
159 NavitGraphics.callback_handler.sendMessage(msg);
160 }
161
162 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
163 }
164
165 static void DR_set_position(String key, Bundle extras, boolean disable_loc)
166 {
167 if (disable_loc)
168 {
169 disable_normal_location();
170 }
171
172 Object value = extras.get(key);
173 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
174 float lat = Float.parseFloat(value2.split(",", 4)[0]);
175 float lon = Float.parseFloat(value2.split(",", 4)[1]);
176 float speed = Float.parseFloat(value2.split(",", 4)[2]);
177 float direction = Float.parseFloat(value2.split(",", 4)[3]);
178 if (direction < 0)
179 {
180 direction = direction + 360;
181 }
182 else if (direction > 360)
183 {
184 direction = direction - 360;
185 }
186
187 Message msg = new Message();
188 Bundle b = new Bundle();
189 b.putInt("Callback", 97);
190 b.putString("lat", String.valueOf(lat));
191 b.putString("lon", String.valueOf(lon));
192 b.putString("q", "POSITION");
193 msg.setData(b);
194 // *DISABLE* Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
195
196 Location l = new Location("ZANavi Comm");
197 // if (NavitVehicle.fastProvider_s == null)
198 // {
199 // l = new Location("ZANavi Comm");
200 // }
201 // else
202 // {
203 // l = new Location(NavitVehicle.fastProvider_s);
204 // }
205 l.setLatitude(lat);
206 l.setLongitude(lon);
207 l.setBearing(direction);
208 l.setSpeed(speed);
209 l.setAccuracy(4.0f); // accuracy 4 meters
210 // NavitVehicle.update_compass_heading(direction);
211 NavitVehicle.set_mock_location__fast(l);
212
213 // System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
214 // System.out.println("ZANaviDebugReceiver:" + "speed=" + speed + " dir=" + direction);
215 }
216
217 static void DR_save_route_to_gpx_file()
218 {
219 Message msg = new Message();
220 Bundle b = new Bundle();
221 b.putInt("Callback", 96);
222 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
223 String filename = Navit.NAVIT_DATA_DEBUG_DIR + "/zanavi_route_" + date + ".gpx";
224 b.putString("s", filename);
225 msg.setData(b);
226 NavitGraphics.callback_handler.sendMessage(msg);
227 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
228 }
229
230 static void DR_save_route_to_gpx_file_with_name(String name)
231 {
232 Message msg = new Message();
233 Bundle b = new Bundle();
234 b.putInt("Callback", 96);
235 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
236 String filename = name;
237 b.putString("s", filename);
238 msg.setData(b);
239 NavitGraphics.callback_handler.sendMessage(msg);
240 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
241 }
242
243 static void DR_clear_route()
244 {
245 // clear any previous destinations
246 Message msg2 = new Message();
247 Bundle b2 = new Bundle();
248 b2.putInt("Callback", 7);
249 msg2.setData(b2);
250 NavitGraphics.callback_handler.sendMessage(msg2);
251 System.out.println("ZANaviDebugReceiver:" + "clear route");
252 }
253
254 static void DR_rewind_small()
255 {
256 rewind_count = 20;
257 System.out.println("ZANaviDebugReceiver:" + "rewind_small");
258 }
259
260 static void DR_skip()
261 {
262 skip_count = 0;
263 System.out.println("ZANaviDebugReceiver:" + "skip");
264 }
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.write(Navit.CI_TEST_CASE_TEXT);
797 }
798 catch (Exception e)
799 {
800 System.out.println("_DREX_:046freetext" + e.getMessage());
801 }
802
803 try
804 {
805 out.flush();
806 out.close();
807 outf.flush();
808 outf.close();
809 }
810 catch (Exception e)
811 {
812 System.out.println("_DREX_:016" + e.getMessage());
813 }
814 }
815 }
816 // else
817 // {
818 // System.out.println("_DRxx_:017" + "Roadbook items = NULL !!");
819 // }
820
821 // calculate success criterion ----------------------
822 // calculate success criterion ----------------------
823
824 result_code = -1;
825
826 if ((!success_operator.equals("")) && (!success_value.equals("")))
827 {
828 System.out.println("roadbook:so=" + success_source);
829 System.out.println("roadbook:it=" + success_item);
830 System.out.println("roadbook:sv=" + success_value);
831
832 if (success_source.equalsIgnoreCase("'dbus'"))
833 {
834 if (success_item.equalsIgnoreCase("'status'"))
835 {
836 int s = NavitGraphics.navit_route_status;
837 int v = Integer.parseInt(success_value);
838
839 if ((success_operator.contains(">")) || ((success_operator.contains("<"))))
840 {
841 if (s == 17)
842 {
843 s = 33;
844 }
845 }
846 else
847 {
848 if (v == 33)
849 {
850 v = 17;
851 if (s == 33)
852 {
853 s = 17;
854 }
855 }
856 else if (v == 17)
857 {
858 if (s == 33)
859 {
860 s = 17;
861 }
862 }
863 }
864 result_code = success_value_compare(s, v);
865
866 System.out.println("roadbook:003:" + s + " " + v);
867 }
868 else if (success_item.equalsIgnoreCase("'distance'"))
869 {
870 int s = local_meters_value;
871 int v = Integer.parseInt(success_value);
872 result_code = success_value_compare(s, v);
873
874 System.out.println("roadbook:001:" + s + " " + v);
875 }
876 }
877 else if (success_source.equalsIgnoreCase("'gpx'"))
878 {
879 if (success_item.equalsIgnoreCase("'nodes'"))
880 {
881 int s = -99;
882 s = (separated.length - 2);
883 int v = Integer.parseInt(success_value);
884 result_code = success_value_compare(s, v);
885
886 System.out.println("roadbook:002:" + s + " " + v);
887 }
888 else if (success_item.startsWith("'nav"))
889 {
890 String nav_num_str = success_item.replace("'nav", "").replace("'", "");
891 int nav_num = Integer.parseInt(nav_num_str);
892
893 if (separated.length > (nav_num + 2))
894 {
895 // ok we have enough entries in roadbook
896
897 String[] values = new String[5];
898 String[] values2 = separated[nav_num + 2].split(":");
899 values[0] = values2[0];
900 values[1] = values2[1];
901 values[2] = values2[2];
902 values[3] = values2[3];
903 try
904 {
905 values[4] = values2[4];
906 }
907 catch (Exception ee)
908 {
909 values[4] = "";
910 System.out.println("_DREX_:006entries" + ee.getMessage());
911 }
912 // 0 string:distance short form
913 // 1 lat
914 // 2 lon
915 // 3 icon name
916 // 4 text
917
918 if (values[3].equalsIgnoreCase(success_value))
919 {
920 result_code = 0;
921 }
922 else
923 {
924 result_code = -1;
925 }
926 }
927 else
928 {
929 // not enough entries in roadbook --> fail
930 result_code = -1;
931 }
932
933 System.out.println("roadbook:002:" + success_item + " " + success_value);
934 }
935
936 }
937 }
938
939 System.out.println("++--------++ roadbook:RES=" + result_code);
940
941 if (result_code == 0)
942 {
943 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
944 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
945 File f2 = new File(orig);
946 File f2_to = new File(rename_to);
947 f2.renameTo(f2_to);
948
949 yaml_err--;
950 }
951 else
952 {
953 }
954
955 // calculate success criterion ----------------------
956 // calculate success criterion ----------------------
957
958 }
959
960 }
961 catch (Exception ebig)
962 {
963 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
964 }
965
966 flag_route_ready = true;
967 }
968 };
969 debug_zoom_to_route_001.start();
970 debug_zoom_to_route_001.join();
971 Thread.sleep(500);
972
973 is_replaying = false;
974 NavitGraphics.NavitAOverlay_s.postInvalidate();
975 br.close();
976 }
977 }
978 catch (Exception e)
979 {
980 System.out.println("_DREX_:011" + e.getMessage());
981 is_replaying = false;
982 NavitGraphics.NavitAOverlay_s.postInvalidate();
983 }
984 }
985
986 static void DR_replay_yaml_file_search_n(String filename, final String date)
987 {
988
989 file_name_global = filename;
990
991 yaml_err++; // incr. error count (on success later -> decrease it again)
992
993 try
994 {
995 if ((filename != null) && (!filename.equals("")))
996 {
997 BufferedReader br = null;
998 br = new BufferedReader(new FileReader(filename));
999
1000 is_replaying = true;
1001 NavitGraphics.NavitAOverlay_s.postInvalidate();
1002
1003 disable_normal_location();
1004
1005 DR_clear_route();
1006 Thread.sleep(1000);
1007
1008 String str_str = "";
1009 String city_str = "";
1010 String hn_str = "";
1011
1012 String mode = "-";
1013 String line = "";
1014 while ((line = br.readLine()) != null)
1015 {
1016 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1017 {
1018 mode = "type";
1019 }
1020 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1021 {
1022 mode = "input";
1023 }
1024 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1025 {
1026 mode = "success";
1027 }
1028 else if ((line.length() > 2) && (!line.startsWith("#")))
1029 {
1030 try
1031 {
1032 if (mode == "success")
1033 {
1034 String name_str = line.split(":", 2)[0].replace(" ", "");
1035 String value_str = line.split(":", 2)[1].replace(" ", "");
1036
1037 if (name_str.equalsIgnoreCase("item"))
1038 {
1039 success_item = value_str;
1040 }
1041 else if (name_str.equalsIgnoreCase("value"))
1042 {
1043 success_value = value_str;
1044 }
1045 else if (name_str.equalsIgnoreCase("operator"))
1046 {
1047 success_operator = value_str;
1048 }
1049 }
1050 else if (mode == "type")
1051 {
1052 // do nothing
1053 }
1054 else
1055 {
1056 String name_str = line.split(":", 2)[0];
1057 String value_str = line.split(":", 2)[1];
1058
1059 if (name_str.contains("street"))
1060 {
1061 str_str = value_str;
1062 }
1063 else if (name_str.contains("city"))
1064 {
1065 city_str = value_str;
1066 }
1067 else if (name_str.contains("housenumber"))
1068 {
1069 hn_str = value_str;
1070 }
1071 }
1072 }
1073 catch (Exception e2)
1074 {
1075 System.out.println("_DREX_:001" + e2.getMessage());
1076 }
1077 }
1078 }
1079
1080 try
1081 {
1082 int jj = 0;
1083 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1084 {
1085 jj++;
1086 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1087 // wait for old route to be cleared
1088 Thread.sleep(1000);
1089 }
1090 }
1091 catch (Exception e)
1092 {
1093 e.printStackTrace();
1094 }
1095
1096 final String str_str_f = str_str;
1097 final String city_str_f = city_str;
1098 final String hn_str_f = hn_str;
1099
1100 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1101
1102 final Thread search_n_002 = new Thread()
1103 {
1104 int wait = 1;
1105
1106 @Override
1107 public void run()
1108 {
1109 while (wait == 1)
1110 {
1111 try
1112 {
1113 // -------- ST N --------
1114 // -------- ST N --------
1115 // -------- ST N --------
1116
1117 // clear results
1118 Navit.NavitAddressResultList_foundItems.clear();
1119 Navit.Navit_Address_Result_double_index.clear();
1120 Navit.NavitSearchresultBarIndex = -1;
1121 Navit.NavitSearchresultBar_title = "";
1122 Navit.NavitSearchresultBar_text = "";
1123 Navit.search_results_towns = 0;
1124 Navit.search_results_streets = 0;
1125 Navit.search_results_streets_hn = 0;
1126 Navit.search_results_poi = 0;
1127
1128 Navit.search_list_ready = false;
1129
1130 final Thread tttt2 = new Thread()
1131 {
1132 @Override
1133 public void run()
1134 {
1135 System.out.println("search test 001");
1136 Navit.use_index_search = false;
1137 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, false, true, true);
1138 }
1139 };
1140 tttt2.start();
1141 System.out.println("search test 002");
1142 Thread.sleep(2000);
1143 System.out.println("search test 003");
1144
1145 // -- wait for search result --
1146 int c4 = 0;
1147 boolean no_result = false;
1148 while (Navit.search_ready == false)
1149 {
1150 System.out.println("search test 004:" + c4);
1151 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1152
1153 Thread.sleep(500);
1154 c4++;
1155
1156 if (c4 > (2 * 60) * 40)
1157 {
1158 System.out.println("search test 004a");
1159 Navit.search_ready = true;
1160 no_result = true;
1161 }
1162 }
1163 // -- wait for search result --
1164
1165 Thread.sleep(1500);
1166
1167 System.out.println("search test 005");
1168 c4 = 0;
1169 if (no_result == false)
1170 {
1171 while (Navit.search_list_ready == false)
1172 {
1173 System.out.println("search test 004b:" + c4);
1174 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1175
1176 Thread.sleep(500);
1177 c4++;
1178
1179 if (c4 > (2 * 60) * 2)
1180 {
1181 System.out.println("search test 004ab");
1182 break;
1183 }
1184 }
1185 }
1186 System.out.println("search test 006");
1187
1188 Thread.sleep(5000);
1189
1190 // save screenshot
1191 System.out.println("SCREENSHOT 001");
1192 try
1193 {
1194 File f = new File(file_name_global);
1195 File d2 = new File(f.getParent() + "/" + date + "/");
1196 d2.mkdirs();
1197 Navit.take_phone_screenshot(NavitAddressResultListActivity.NavitAddressResultListActivity_s, f.getParent() + "/" + date + "/", f.getName());
1198 }
1199 catch (Exception ee4)
1200 {
1201 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1202 ee4.printStackTrace();
1203 }
1204 System.out.println("SCREENSHOT 002");
1205
1206 try
1207 {
1208 NavitAddressResultListActivity.force_done();
1209 }
1210 catch (Exception ee4)
1211 {
1212 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1213 ee4.printStackTrace();
1214 }
1215
1216 System.out.println("SCREENSHOT 003");
1217
1218 wait = 0;
1219 // -------- ST N --------
1220 // -------- ST N --------
1221 // -------- ST N --------
1222
1223 FileOutputStream outf = null;
1224 try
1225 {
1226 File f = new File(file_name_global);
1227 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
1228 }
1229 catch (Exception ef)
1230 {
1231 //System.out.println("EE002:" + ef.getMessage());
1232 System.out.println("_DREX_:003" + ef.getMessage());
1233 }
1234
1235 OutputStreamWriter out = null;
1236 try
1237 {
1238 out = new OutputStreamWriter(outf);
1239 }
1240 catch (Exception e)
1241 {
1242 // System.out.println("EE003:" + e.getMessage());
1243 System.out.println("_DREX_:004" + e.getMessage());
1244 }
1245
1246 //System.out.println("Roadbook:length=" + (separated.length - 2));
1247 try
1248 {
1249 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
1250 }
1251 catch (Exception e)
1252 {
1253 //System.out.println("EE004:" + e.getMessage());
1254 System.out.println("_DREX_:005" + e.getMessage());
1255 }
1256
1257 try
1258 {
1259 int i = 0;
1260 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
1261 {
1262 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");
1263 }
1264 }
1265 catch (Exception e)
1266 {
1267 //System.out.println("EE004:" + e.getMessage());
1268 System.out.println("_DREX_:005a" + e.getMessage());
1269 }
1270
1271 try
1272 {
1273 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");
1274 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");
1275 // out.write("URL3:" + "about:\n");
1276 }
1277 catch (Exception e)
1278 {
1279 System.out.println("_DREX_:046" + e.getMessage());
1280 }
1281
1282 try
1283 {
1284 out.flush();
1285 out.close();
1286 outf.flush();
1287 outf.close();
1288 }
1289 catch (Exception e)
1290 {
1291 System.out.println("_DREX_:016" + e.getMessage());
1292 }
1293
1294 // calculate success criterion ----------------------
1295 // calculate success criterion ----------------------
1296
1297 result_code = -1;
1298
1299 if ((!success_operator.equals("")) && (!success_value.equals("")))
1300 {
1301 // System.out.println("search:so=" + success_source);
1302 System.out.println("search:it=" + success_item);
1303 System.out.println("search:sv=" + success_value);
1304
1305 if (success_item.equalsIgnoreCase("'resultcount'"))
1306 {
1307 try
1308 {
1309 int s = Navit.NavitAddressResultList_foundItems.size();
1310 int v = Integer.parseInt(success_value);
1311 result_code = success_value_compare(s, v);
1312 }
1313 catch (Exception e)
1314 {
1315 result_code = -1;
1316 }
1317 }
1318 }
1319
1320 // dummy for circleCI
1321 File f3 = new File(file_name_global);
1322 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1323 // dummy for circleCI
1324
1325 if (result_code == 0)
1326 {
1327 File f = new File(file_name_global);
1328 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
1329 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
1330 File f2 = new File(orig);
1331 File f2_to = new File(rename_to);
1332 f2.renameTo(f2_to);
1333
1334 yaml_err--;
1335 }
1336 else
1337 {
1338 }
1339
1340 // calculate success criterion ----------------------
1341 // calculate success criterion ----------------------
1342
1343 }
1344 catch (Exception ebig)
1345 {
1346 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1347 }
1348 }
1349 }
1350 };
1351 search_n_002.start();
1352 search_n_002.join();
1353 Thread.sleep(500);
1354
1355 is_replaying = false;
1356 NavitGraphics.NavitAOverlay_s.postInvalidate();
1357 br.close();
1358 }
1359 }
1360 catch (Exception e)
1361 {
1362 System.out.println("_DREX_:011" + e.getMessage());
1363 is_replaying = false;
1364 NavitGraphics.NavitAOverlay_s.postInvalidate();
1365 }
1366 }
1367
1368 static void DR_replay_yaml_file_search_i(String filename, final String date)
1369 {
1370
1371 file_name_global = filename;
1372
1373 yaml_err++; // incr. error count (on success later -> decrease it again)
1374
1375 try
1376 {
1377 if ((filename != null) && (!filename.equals("")))
1378 {
1379 BufferedReader br = null;
1380 br = new BufferedReader(new FileReader(filename));
1381
1382 is_replaying = true;
1383 NavitGraphics.NavitAOverlay_s.postInvalidate();
1384
1385 disable_normal_location();
1386
1387 DR_clear_route();
1388 Thread.sleep(1000);
1389
1390 String str_str = "";
1391 String city_str = "";
1392 String hn_str = "";
1393
1394 String mode = "-";
1395 String line = "";
1396 while ((line = br.readLine()) != null)
1397 {
1398 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1399 {
1400 mode = "type";
1401 }
1402 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1403 {
1404 mode = "input";
1405 }
1406 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1407 {
1408 mode = "success";
1409 }
1410 else if ((line.length() > 2) && (!line.startsWith("#")))
1411 {
1412 try
1413 {
1414 if (mode == "success")
1415 {
1416 String name_str = line.split(":", 2)[0].replace(" ", "");
1417 String value_str = line.split(":", 2)[1].replace(" ", "");
1418
1419 if (name_str.equalsIgnoreCase("item"))
1420 {
1421 success_item = value_str;
1422 }
1423 else if (name_str.equalsIgnoreCase("value"))
1424 {
1425 success_value = value_str;
1426 }
1427 else if (name_str.equalsIgnoreCase("operator"))
1428 {
1429 success_operator = value_str;
1430 }
1431 }
1432 else if (mode == "type")
1433 {
1434 // do nothing
1435 }
1436 else
1437 {
1438 String name_str = line.split(":", 2)[0];
1439 String value_str = line.split(":", 2)[1];
1440
1441 if (name_str.contains("street"))
1442 {
1443 str_str = value_str;
1444 }
1445 else if (name_str.contains("city"))
1446 {
1447 city_str = value_str;
1448 }
1449 else if (name_str.contains("housenumber"))
1450 {
1451 hn_str = value_str;
1452 }
1453 }
1454 }
1455 catch (Exception e2)
1456 {
1457 System.out.println("_DREX_:001" + e2.getMessage());
1458 }
1459 }
1460 }
1461
1462 try
1463 {
1464 int jj = 0;
1465 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1466 {
1467 jj++;
1468 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1469 // wait for old route to be cleared
1470 Thread.sleep(1000);
1471 }
1472 }
1473 catch (Exception e)
1474 {
1475 e.printStackTrace();
1476 }
1477
1478 final String str_str_f = str_str;
1479 final String city_str_f = city_str;
1480 final String hn_str_f = hn_str;
1481
1482 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1483
1484 final Thread search_n_001 = new Thread()
1485 {
1486 int wait = 1;
1487
1488 @Override
1489 public void run()
1490 {
1491 while (wait == 1)
1492 {
1493 try
1494 {
1495
1496 // -------- ST I --------
1497 // -------- ST I --------
1498 // -------- ST I --------
1499
1500 // clear results
1501 Navit.NavitAddressResultList_foundItems.clear();
1502 Navit.Navit_Address_Result_double_index.clear();
1503 Navit.NavitSearchresultBarIndex = -1;
1504 Navit.NavitSearchresultBar_title = "";
1505 Navit.NavitSearchresultBar_text = "";
1506 Navit.search_results_towns = 0;
1507 Navit.search_results_streets = 0;
1508 Navit.search_results_streets_hn = 0;
1509 Navit.search_results_poi = 0;
1510
1511 final Thread tttt2 = new Thread()
1512 {
1513 @Override
1514 public void run()
1515 {
1516 System.out.println("search test 001");
1517 Navit.use_index_search = true;
1518 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, true, true, true);
1519 }
1520 };
1521 tttt2.start();
1522 System.out.println("search test 002");
1523 Thread.sleep(2000);
1524 System.out.println("search test 003");
1525
1526 // -- wait for search result --
1527 int c4 = 0;
1528 boolean no_result = false;
1529 Navit.search_list_ready = false;
1530 while (Navit.search_ready == false)
1531 {
1532 System.out.println("search test 004:" + c4);
1533 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1534
1535 Thread.sleep(500);
1536 c4++;
1537
1538 if (c4 > (2 * 60) * 40)
1539 {
1540 System.out.println("search test 004a");
1541 Navit.search_ready = true;
1542 no_result = true;
1543 }
1544 }
1545 // -- wait for search result --
1546
1547 System.out.println("search test 005");
1548
1549 Thread.sleep(6000);
1550
1551 Navit.runOnUI(new Runnable()
1552 {
1553 @Override
1554 public void run()
1555 {
1556 try
1557 {
1558 System.out.println("hide keyboard-1");
1559 // now hide the keyboard
1560 InputMethodManager inputManager = (InputMethodManager) Navit.Global_Navit_Object.getSystemService(Context.INPUT_METHOD_SERVICE);
1561 inputManager.hideSoftInputFromWindow(Navit.Global_Navit_Object.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
1562 inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
1563 System.out.println("hide keyboard-2");
1564 }
1565 catch (Exception e)
1566 {
1567 e.printStackTrace();
1568 System.out.println("hide keyboard-3");
1569 }
1570 }
1571 });
1572
1573 System.out.println("search test 005");
1574 Thread.sleep(1500);
1575
1576 // save screenshot
1577 System.out.println("SCREENSHOT 001");
1578 try
1579 {
1580 File f = new File(file_name_global);
1581 File d2 = new File(f.getParent() + "/" + date + "/");
1582 d2.mkdirs();
1583 Navit.take_phone_screenshot(NavitAddressSearchActivity.NavitAddressSearchActivity_s, f.getParent() + "/" + date + "/", f.getName());
1584 }
1585 catch (Exception ee4)
1586 {
1587 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1588 ee4.printStackTrace();
1589 }
1590 System.out.println("SCREENSHOT 002");
1591
1592 try
1593 {
1594 NavitAddressSearchActivity.force_done();
1595 }
1596 catch (Exception ee4)
1597 {
1598 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1599 ee4.printStackTrace();
1600 }
1601
1602 System.out.println("SCREENSHOT 003");
1603
1604 wait = 0;
1605 // -------- ST I --------
1606 // -------- ST I --------
1607 // -------- ST I --------
1608
1609 FileOutputStream outf = null;
1610 try
1611 {
1612 File f = new File(file_name_global);
1613 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
1614 }
1615 catch (Exception ef)
1616 {
1617 //System.out.println("EE002:" + ef.getMessage());
1618 System.out.println("_DREX_:003" + ef.getMessage());
1619 }
1620
1621 OutputStreamWriter out = null;
1622 try
1623 {
1624 out = new OutputStreamWriter(outf);
1625 }
1626 catch (Exception e)
1627 {
1628 // System.out.println("EE003:" + e.getMessage());
1629 System.out.println("_DREX_:004" + e.getMessage());
1630 }
1631
1632 //System.out.println("Roadbook:length=" + (separated.length - 2));
1633 try
1634 {
1635 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
1636 }
1637 catch (Exception e)
1638 {
1639 //System.out.println("EE004:" + e.getMessage());
1640 System.out.println("_DREX_:005" + e.getMessage());
1641 }
1642
1643 try
1644 {
1645 int i = 0;
1646 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
1647 {
1648 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");
1649 }
1650 }
1651 catch (Exception e)
1652 {
1653 //System.out.println("EE004:" + e.getMessage());
1654 System.out.println("_DREX_:005a" + e.getMessage());
1655 }
1656
1657 try
1658 {
1659 // http://nominatim.openstreetmap.org/search.php?q=wienerneustadt+blubgasse+99
1660 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");
1661 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");
1662 // out.write("URL3:" + "\n");
1663 }
1664 catch (Exception e)
1665 {
1666 System.out.println("_DREX_:046" + e.getMessage());
1667 }
1668
1669 try
1670 {
1671 out.flush();
1672 out.close();
1673 outf.flush();
1674 outf.close();
1675 }
1676 catch (Exception e)
1677 {
1678 System.out.println("_DREX_:016" + e.getMessage());
1679 }
1680
1681 // calculate success criterion ----------------------
1682 // calculate success criterion ----------------------
1683
1684 result_code = -1;
1685
1686 if ((!success_operator.equals("")) && (!success_value.equals("")))
1687 {
1688 // System.out.println("search:so=" + success_source);
1689 System.out.println("search:it=" + success_item);
1690 System.out.println("search:sv=" + success_value);
1691
1692 if (success_item.equalsIgnoreCase("'resultcount'"))
1693 {
1694 try
1695 {
1696 int s = Navit.NavitAddressResultList_foundItems.size();
1697 int v = Integer.parseInt(success_value);
1698 result_code = success_value_compare(s, v);
1699 }
1700 catch (Exception e)
1701 {
1702 result_code = -1;
1703 }
1704 }
1705 }
1706
1707 // dummy for circleCI
1708 File f3 = new File(file_name_global);
1709 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1710 // dummy for circleCI
1711
1712 if (result_code == 0)
1713 {
1714 File f = new File(file_name_global);
1715 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
1716 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
1717 File f2 = new File(orig);
1718 File f2_to = new File(rename_to);
1719 f2.renameTo(f2_to);
1720
1721 yaml_err--;
1722 }
1723 else
1724 {
1725 }
1726
1727 // calculate success criterion ----------------------
1728 // calculate success criterion ----------------------
1729
1730 }
1731 catch (Exception ebig)
1732 {
1733 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1734 }
1735 }
1736 }
1737 };
1738 search_n_001.start();
1739 search_n_001.join();
1740 Thread.sleep(500);
1741
1742 is_replaying = false;
1743 NavitGraphics.NavitAOverlay_s.postInvalidate();
1744 br.close();
1745 }
1746 }
1747 catch (Exception e)
1748 {
1749 System.out.println("_DREX_:011" + e.getMessage());
1750 is_replaying = false;
1751 NavitGraphics.NavitAOverlay_s.postInvalidate();
1752 }
1753 }
1754
1755 static int success_value_compare(int s, int v)
1756 {
1757 if (success_operator.equalsIgnoreCase("'=='"))
1758 {
1759 if (s == v)
1760 {
1761 return 0;
1762 }
1763 }
1764 else if (success_operator.equalsIgnoreCase("'<>'"))
1765 {
1766 if (s != v)
1767 {
1768 return 0;
1769 }
1770 }
1771 else if (success_operator.equalsIgnoreCase("'!='"))
1772 {
1773 if (s != v)
1774 {
1775 return 0;
1776 }
1777 }
1778 else if (success_operator.equalsIgnoreCase("'<'"))
1779 {
1780 if (s < v)
1781 {
1782 return 0;
1783 }
1784 }
1785 else if (success_operator.equalsIgnoreCase("'<='"))
1786 {
1787 if (s <= v)
1788 {
1789 return 0;
1790 }
1791 }
1792 else if (success_operator.equalsIgnoreCase("'=<'"))
1793 {
1794 if (s <= v)
1795 {
1796 return 0;
1797 }
1798 }
1799 else if (success_operator.equalsIgnoreCase("'>'"))
1800 {
1801 if (s > v)
1802 {
1803 return 0;
1804 }
1805 }
1806 else if (success_operator.equalsIgnoreCase("'>='"))
1807 {
1808 if (s >= v)
1809 {
1810 return 0;
1811 }
1812 }
1813 else if (success_operator.equalsIgnoreCase("'=>'"))
1814 {
1815 if (s >= v)
1816 {
1817 return 0;
1818 }
1819 }
1820
1821 return -1;
1822 }
1823
1824 static void DR_run_all_yaml_tests()
1825 {
1826 String yaml_dir = Navit.NAVIT_DATA_DEBUG_DIR + "../yamltests/";
1827 String duration_string = "";
1828
1829 try
1830 {
1831 File dir = new File(yaml_dir);
1832 try
1833 {
1834 dir.mkdirs();
1835 }
1836 catch (Exception e2)
1837 {
1838 // System.out.println("XXXX:E01" + e2.getMessage());
1839 System.out.println("_DREX_:012" + e2.getMessage());
1840 }
1841
1842 Navit.static_show_route_graph(4);
1843
1844 String date_str = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
1845
1846 FilenameFilter textFilter = new FilenameFilter()
1847 {
1848 public boolean accept(File dir, String name)
1849 {
1850 String lowercaseName = name.toLowerCase(Locale.GERMAN);
1851 if (lowercaseName.endsWith(".yaml"))
1852 {
1853 return true;
1854 }
1855 else
1856 {
1857 return false;
1858 }
1859 }
1860 };
1861
1862 System.out.println("XXXX:1:" + dir);
1863
1864 yaml_sum = 0;
1865 yaml_err = 0;
1866 BufferedReader br = null;
1867 String line2 = "";
1868
1869 File[] directoryListing = dir.listFiles(textFilter);
1870 if (directoryListing != null)
1871 {
1872 for (File yamlfile : directoryListing)
1873 {
1874 yaml_sum++;
1875
1876 final Thread temp_work_thread = new Thread()
1877 {
1878 @Override
1879 public void run()
1880 {
1881 try
1882 {
1883 //if (Navit.CIDEBUG > 0) // automatic debug run
1884 //{
1885 // Navit.show_geo_on_screen_no_draw(0, 0);
1886 // Thread.sleep(200);
1887 // Navit.set_zoom_level_no_draw((int) Math.pow(2, 5)); // zoom level: (18 - 5) = 13
1888 // Thread.sleep(200);
1889 //}
1890 //else
1891 //{
1892 Navit.show_geo_on_screen_no_draw(0, 0);
1893 Thread.sleep(150);
1894 Navit.set_zoom_level_no_draw((int) Math.pow(2, 17));
1895 Thread.sleep(120);
1896 //}
1897 }
1898 catch (Exception e2)
1899 {
1900 System.out.println("_DREX_:013" + e2.getMessage());
1901 e2.printStackTrace();
1902 }
1903 }
1904 };
1905 temp_work_thread.start();
1906 temp_work_thread.join();
1907
1908 System.out.println("XXXX:2:1:" + "");
1909
1910 Navit.CI_TEST_CASE_NUM++;
1911 Navit.CI_TEST_CASE_TEXT = Navit.CI_TEST_CASE_TEXT + "\n" + "===========" + Navit.CI_TEST_CASE_NUM + "===========" + "\n";
1912 try
1913 {
1914 NavitGraphics.CallbackMessageChannelReal(115, "" + Navit.CI_TEST_CASE_NUM);
1915 }
1916 catch (Exception e)
1917 {
1918 }
1919
1920 System.out.println("XXXX:2:2:" + "");
1921 System.out.println("XXXX:2:3:" + "======= START =======");
1922 long startTime = System.currentTimeMillis();
1923 System.out.println("XXXX:2:4:" + yamlfile.getAbsolutePath());
1924
1925 br = null;
1926 line2 = "";
1927 try
1928 {
1929 br = new BufferedReader(new FileReader(yamlfile.getAbsolutePath()));
1930 line2 = br.readLine();
1931 }
1932 catch (Exception e66)
1933 {
1934 }
1935
1936 if ((line2.length() >= "type:".length()) && (line2.equals("type: 'NS'")))
1937 {
1938 DR_replay_yaml_file_search_n(yamlfile.getAbsolutePath(), date_str);
1939 }
1940 else if ((line2.length() >= "type:".length()) && (line2.equals("type: 'IS'")))
1941 {
1942 DR_replay_yaml_file_search_i(yamlfile.getAbsolutePath(), date_str);
1943 }
1944 else
1945 {
1946 DR_replay_gps_file(yamlfile.getAbsolutePath(), date_str);
1947 }
1948
1949 System.out.println("XXXX:2:5:" + yamlfile.getAbsolutePath());
1950 float difference = (float) (System.currentTimeMillis() - startTime);
1951 duration_string = duration_string + yamlfile.getName() + ":" + (difference / 1000.0f) + "\n";
1952 System.out.println("XXXX:2:6:" + "======= END ======= duration: " + (difference / 1000.0f) + " secs.");
1953 System.out.println("XXXX:2:7:" + "");
1954 Navit.CI_TEST_CASE_TEXT = "";
1955 System.out.println("XXXX:2:8:" + "");
1956
1957 //xy//Thread.sleep(1500);
1958
1959 }
1960 }
1961 }
1962 catch (Exception e)
1963 {
1964 // System.out.println("XXXX:E02" + e.getMessage());
1965 System.out.println("_DREX_:019" + e.getMessage());
1966 }
1967
1968 try
1969 {
1970 FileOutputStream outf = null;
1971 OutputStreamWriter out = null;
1972 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_DURATION_XX_XX_.txt");
1973 out = new OutputStreamWriter(outf);
1974 out.write(duration_string);
1975 out.flush();
1976 out.close();
1977 }
1978 catch (Exception ef2)
1979 {
1980 System.out.println("_DREX_:034" + ef2.getMessage());
1981 }
1982
1983 try
1984 {
1985 FileOutputStream outf = null;
1986 OutputStreamWriter out = null;
1987 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_SUMMARY_XX_XX_.txt");
1988 out = new OutputStreamWriter(outf);
1989 out.write("tests:" + yaml_sum + "\n");
1990 out.write("errors:" + yaml_err + "\n");
1991 if (yaml_err > 0)
1992 {
1993 out.write("RES:" + "ERR" + "\n");
1994 }
1995 else
1996 {
1997 out.write("RES:" + "OK" + "\n");
1998 }
1999 out.flush();
2000 out.close();
2001 }
2002 catch (Exception ef2)
2003 {
2004 System.out.println("_DREX_:014" + ef2.getMessage());
2005 // System.out.println("EE00SUM:" + ef2.getMessage());
2006 }
2007
2008 DR_clear_route();
2009
2010 // restore normal state ----------------------
2011 Navit.static_show_route_graph(3);
2012 enable_normal_location();
2013 // restore normal state ----------------------
2014 }
2015
2016 static void DR_replay_gps_file(String filename, String date_str)
2017 {
2018
2019 System.out.println("ZANaviDebugReceiver:" + "Enter!!");
2020
2021 stop_me = false;
2022 dont_save_loc = true;
2023
2024 try
2025 {
2026 if ((filename != null) && (!filename.equals("")))
2027 {
2028
2029 if (filename.endsWith("yaml"))
2030 {
2031 DR_replay_yaml_file(filename, date_str);
2032 return;
2033 }
2034
2035 BufferedReader br = null;
2036 br = new BufferedReader(new FileReader(filename));
2037
2038 Bundle extras2;
2039
2040 String line = "";
2041 String[] line_parts;
2042
2043 skip_count = skip;
2044 is_replaying = true;
2045 NavitGraphics.NavitAOverlay_s.postInvalidate();
2046
2047 long line_number = 0;
2048
2049 disable_normal_location();
2050
2051 while ((line = br.readLine()) != null)
2052 {
2053 //if (line.length() > 1)
2054 //{
2055 // System.out.println("ZANaviDebugReceiver:" + "line=" + line);
2056 //}
2057
2058 line_number++;
2059
2060 if (stop_me == true)
2061 {
2062 try
2063 {
2064 br.close();
2065 }
2066 catch (Exception ce)
2067 {
2068 ce.printStackTrace();
2069 }
2070
2071 is_replaying = false;
2072 NavitGraphics.NavitAOverlay_s.postInvalidate();
2073 return;
2074 }
2075
2076 if ((rewind_count > 0) && (skip_count == skip))
2077 {
2078 try
2079 {
2080 // seek to start of file and skip lines
2081 br.close();
2082 br = new BufferedReader(new FileReader(filename));
2083
2084 line_number = line_number - rewind_count;
2085 rewind_count = 0;
2086 int l_new = 0;
2087
2088 while (line_number > 0)
2089 {
2090 // just skip lines
2091 line = br.readLine();
2092 // System.out.println("ZANaviDebugReceiver:" + "skip line:" + line + " l=" + l_new);
2093 line_number--;
2094 l_new++;
2095 }
2096
2097 line_number = l_new;
2098 }
2099 catch (Exception ce)
2100 {
2101 ce.printStackTrace();
2102 }
2103 }
2104
2105 if (line.length() > 3)
2106 {
2107 extras2 = new Bundle();
2108 line_parts = line.split(":", 2);
2109
2110 if (line_parts[0].equals("CLR"))
2111 {
2112 if (skip_count >= skip)
2113 {
2114 DR_clear_route();
2115 Thread.sleep(200);
2116 }
2117 else
2118 {
2119 skip_count++;
2120 }
2121 }
2122 else if (line_parts[0].equals("DST"))
2123 {
2124 if (skip_count >= skip)
2125 {
2126 extras2.putString("add_destination", line_parts[1]);
2127 DR_add_destination("add_destination", extras2);
2128 Thread.sleep(5000); // wait 5 seconds to calc route
2129 }
2130 else
2131 {
2132 skip_count++;
2133 }
2134 }
2135 else if (line_parts[0].equals("POS"))
2136 {
2137 while (Navit.follow_current == Navit.follow_off)
2138 {
2139 try
2140 {
2141 Thread.sleep(600);
2142 }
2143 catch (Exception sl1)
2144 {
2145 }
2146 }
2147
2148 if (skip_count >= skip)
2149 {
2150 extras2.putString("set_position", line_parts[1]);
2151 DR_set_position("set_position", extras2, false);
2152 Thread.sleep(950); // about 1 second between locationpoints
2153 }
2154 else
2155 {
2156 skip_count++;
2157 }
2158 }
2159 else
2160 {
2161 }
2162
2163 }
2164 }
2165
2166 is_replaying = false;
2167 System.out.println("ZANaviDebugReceiver:" + "while loop end");
2168 br.close();
2169 }
2170
2171 }
2172 catch (Exception e)
2173 {
2174 System.out.println("_DREX_:015" + e.getMessage());
2175 e.printStackTrace();
2176 System.out.println("ZANaviDebugReceiver:" + "EX:" + e.getMessage());
2177 }
2178
2179 is_replaying = false;
2180 dont_save_loc = true;
2181
2182 NavitGraphics.NavitAOverlay_s.postInvalidate();
2183
2184 System.out.println("ZANaviDebugReceiver:" + "Leave!!");
2185 }
2186
2187 @Override
2188 public void onReceive(Context context, Intent intent)
2189 {
2190 if (Navit.p.PREF_enable_debug_enable_comm)
2191 {
2192 System.out.println("ZANaviDebugReceiver:" + "enter");
2193 try
2194 {
2195 Bundle extras = intent.getExtras();
2196 // System.out.println("ZANaviDebugReceiver:" + "command " + extras.toString());
2197
2198 if (extras != null)
2199 {
2200 for (String key : extras.keySet())
2201 {
2202 if (key.equals("set_position2"))
2203 {
2204 Object value = extras.get(key);
2205 String value2 = value.toString().replaceAll("\\s+", "").replaceAll("\"", "");
2206 float lat = Float.parseFloat(value2.split(",", 2)[0]);
2207 float lon = Float.parseFloat(value2.split(",", 2)[1]);
2208 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2209
2210 Message msg = new Message();
2211 Bundle b = new Bundle();
2212 b.putInt("Callback", 97);
2213 b.putString("lat", String.valueOf(lat));
2214 b.putString("lon", String.valueOf(lon));
2215 b.putString("q", "POSITION");
2216 msg.setData(b);
2217 NavitGraphics.callback_handler.sendMessage(msg);
2218
2219 break;
2220 }
2221 else if (key.equals("set_pos_and_dest"))
2222 {
2223 Object value = extras.get(key);
2224 String value2 = value.toString().replaceAll("\"", "");
2225 // String route_name = value2.split(" ", 5)[0];
2226 float lat1 = Float.parseFloat(value2.split(" ", 5)[2]);
2227 float lon1 = Float.parseFloat(value2.split(" ", 5)[1]);
2228 float lat2 = Float.parseFloat(value2.split(" ", 5)[4]);
2229 float lon2 = Float.parseFloat(value2.split(" ", 5)[3]);
2230
2231 System.out.println("ZANaviDebugReceiver:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2232
2233 DR_clear_route();
2234 Thread.sleep(200);
2235 extras = new Bundle();
2236 extras.putString("set_position", "" + lat1 + "," + lon1 + "," + "0.0" + "," + "0");
2237 DR_set_position("set_position", extras, true);
2238 Thread.sleep(1000);
2239 extras = new Bundle();
2240 extras.putString("add_destination", "" + lat2 + "," + lon2);
2241 DR_add_destination("add_destination", extras);
2242
2243 final Thread debug_zoom_to_route_001a = new Thread()
2244 {
2245 int wait = 1;
2246 int count = 0;
2247 int max_count = 60;
2248
2249 @Override
2250 public void run()
2251 {
2252 while (wait == 1)
2253 {
2254 try
2255 {
2256 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
2257 {
2258 // zoom to route
2259 Message msg = new Message();
2260 Bundle b = new Bundle();
2261 b.putInt("Callback", 17);
2262 msg.setData(b);
2263 NavitGraphics.callback_handler.sendMessage(msg);
2264
2265 Navit.set_map_position_to_screen_center();
2266
2267 // save route to gpx file
2268 DR_save_route_to_gpx_file();
2269
2270 wait = 0;
2271 }
2272 else
2273 {
2274 wait = 1;
2275 }
2276
2277 count++;
2278 if (count > max_count)
2279 {
2280 wait = 0;
2281
2282 Message msg7 = Navit.Navit_progress_h.obtainMessage();
2283 Bundle b7 = new Bundle();
2284 msg7.what = 2; // long Toast message
2285 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
2286 msg7.setData(b7);
2287 Navit.Navit_progress_h.sendMessage(msg7);
2288 }
2289 else
2290 {
2291 Thread.sleep(400);
2292 }
2293 }
2294 catch (Exception e)
2295 {
2296 }
2297 }
2298 }
2299 };
2300 debug_zoom_to_route_001a.start();
2301
2302 break;
2303 }
2304 else if (key.equals("set_position"))
2305 {
2306 DR_set_position(key, extras, true);
2307 break;
2308 }
2309 else if (key.equals("add_destination"))
2310 {
2311 DR_add_destination(key, extras);
2312
2313 final Thread debug_zoom_to_route_002 = new Thread()
2314 {
2315 int wait = 1;
2316 int count = 0;
2317 int max_count = 60;
2318
2319 @Override
2320 public void run()
2321 {
2322 while (wait == 1)
2323 {
2324 try
2325 {
2326 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
2327 {
2328 // zoom to route
2329 Message msg = new Message();
2330 Bundle b = new Bundle();
2331 b.putInt("Callback", 17);
2332 msg.setData(b);
2333 NavitGraphics.callback_handler.sendMessage(msg);
2334
2335 Navit.set_map_position_to_screen_center();
2336
2337 wait = 0;
2338 }
2339 else
2340 {
2341 wait = 1;
2342 }
2343
2344 count++;
2345 if (count > max_count)
2346 {
2347 wait = 0;
2348 }
2349 else
2350 {
2351 Thread.sleep(400);
2352 }
2353 }
2354 catch (Exception e)
2355 {
2356 }
2357 }
2358 }
2359 };
2360 debug_zoom_to_route_002.start();
2361
2362 break;
2363 }
2364 else if (key.equals("export_route_gpx"))
2365 {
2366 DR_save_route_to_gpx_file();
2367 break;
2368 }
2369 else if (key.equals("clear_route"))
2370 {
2371 DR_clear_route();
2372 break;
2373 }
2374 else if (key.equals("disable_normal_location"))
2375 {
2376 disable_normal_location();
2377 break;
2378 }
2379 else if (key.equals("enable_normal_location"))
2380 {
2381 NavitVehicle.turn_on_fast_provider();
2382 NavitVehicle.turn_on_precise_provider();
2383 NavitVehicle.turn_on_sat_status();
2384 System.out.println("ZANaviDebugReceiver:" + "enable normal location");
2385 break;
2386 }
2387 }
2388 }
2389 }
2390 catch (Exception e)
2391 {
2392 e.printStackTrace();
2393 }
2394 }
2395 }
2396 }
2397

   
Visit the ZANavi Wiki