yy1717
2021-04-13 89bb77a1280b9a117bfde34cbc62f92582d9a8b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
package safeluck.drive.evaluation.fragment;
 
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.os.Bundle;
 
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
 
import com.anyun.basecommonlib.MyLog;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.PointCollection;
import com.esri.arcgisruntime.geometry.Polygon;
import com.esri.arcgisruntime.geometry.Polyline;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;
import com.esri.arcgisruntime.layers.ArcGISTiledLayer;
import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.MobileMapPackage;
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapScaleChangedEvent;
import com.esri.arcgisruntime.mapping.view.MapScaleChangedListener;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.google.gson.Gson;
 
import org.json.JSONException;
import org.json.JSONObject;
 
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
 
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.DB.exam_status.ExamStatus;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.BaseDataUIBean;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.GisCarModel;
import safeluck.drive.evaluation.bean.MapInfoHead;
import safeluck.drive.evaluation.bean.RTKInfoBean;
import safeluck.drive.evaluation.bean.RealTimeCarPos;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.Utils;
 
/**驾校信息UI
 * MyApplication2
 * Created by lzw on 2019/3/20. 11:22:39
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class ArcGisMapFragment extends SupportFragment implements View.OnClickListener {
 
    private static final String TAG = ArcGisMapFragment.class.getSimpleName();
    private static final int ENTER = 1;//进入 科二某个项目地图
 
    private LinkedBlockingQueue queue = new LinkedBlockingQueue(100);
    private LinkedBlockingQueue queue1 = new LinkedBlockingQueue(100);
    private ExecutorService consumer = Executors.newSingleThreadExecutor();
    private ExecutorService producer = Executors.newSingleThreadExecutor();
    SimpleLineSymbol lineSymbolGls = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 0.5f);
 
 
    PointCollection points = new PointCollection(SpatialReference.create(4544));
    private Gson gson = new Gson();
    private ICEventListener icEventListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
 
 
 
 
                producer.execute(()->{
                    String json = (String)obj;
                    Log.i(TAG,String.format("当前线程号%d,json=%s",Thread.currentThread().getId(),json));
                    RTKInfoBean rtkInfoBean = gson.fromJson(json,RTKInfoBean.class);
                    queue.offer(rtkInfoBean);
                });
 
//                MyLog.i(TAG,"处理完11.时间="+Utils.formatTimeYYMMDDHHmmSSSSS(System.currentTimeMillis()));
 
 
        }
    };
    private ICEventListener icEventListener1 = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode==13){
                ExamStatus examStatus = (ExamStatus)obj;
                if (examStatus.getMap_id()>-1){
                    if (examStatus.getEnter()==ENTER){
                        double scale = mMapView.getMapScale();
                        MyLog.i(TAG,String.format("进入[%d] map,scale=%f",examStatus.getMap_id(),scale));
                        mMapView.setViewpointScaleAsync(scale * 0.5*0.5);
 
 
 
                    }else{
                        double scale = mMapView.getMapScale();
                        MyLog.i(TAG,String.format("退出[%d] map,scale=%f",examStatus.getMap_id(),scale));
 
                        mMapView.setViewpointScaleAsync(scale * 2);
 
                    }
                }
            }
        }
    };
    private SurfaceView mSurfaceView;
    private SurfaceHolder holder;
 
    public static SupportFragment newInstance(String s){
        ArcGisMapFragment jiaXiaoFragment = new ArcGisMapFragment();
        Bundle bundle = new Bundle();
        bundle.putString("arcgis_url",s);
        jiaXiaoFragment.setArguments(bundle);
        return jiaXiaoFragment;
    }
 
 
    private MapView mMapView ;
    private static final int MSG_CAR = 100;
    double yaw = 0;
 
    GraphicsOverlay mGraphicsOverlay;
    GraphicsOverlay mGraphicsOverlay_body;
    private double startY = 428882,startX = 3291858;
    private Handler mHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case MSG_CAR:
 
                    List<safeluck.drive.evaluation.bean.Point> newCarPoints = (List<safeluck.drive.evaluation.bean.Point>) msg.obj;
                    Log.i(TAG,"handle message newcarPoints.size="+newCarPoints.size());
                    drawGlses(newCarPoints,gisCarModel);
                    drawRightPart();
                    break;
            }
        }
    };
 
    PointCollection mPointCollection = new PointCollection(SpatialReference.create(4544));
    private Bitmap bmp2 = null;
    private Paint paint = new Paint();
 
    private Canvas canvas3 = null;
    private int screen_width = 0, screen_height = 0,display_width=0;
    private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
 
 
        View view = inflater.inflate(R.layout.layout_arc_gis,container,false);
        mMapView = view.findViewById(R.id.mapView);
        mMapView.addMapScaleChangedListener(new MapScaleChangedListener() {
            @Override
            public void mapScaleChanged(MapScaleChangedEvent mapScaleChangedEvent) {
                Log.i(TAG,"mapscaleChangelistenre");
            }
        });
        view.findViewById(R.id.btn_change_map).setOnClickListener(this);
        mSurfaceView = view.findViewById(R.id.surfaceview_arcgis);
 
        holder = mSurfaceView.getHolder();
        display_width = getResources().getDisplayMetrics().widthPixels;
        holder.addCallback(new SurfaceHolder.Callback() {
            @Override
            public void surfaceCreated(SurfaceHolder surfaceHolder) {
                Canvas canvas = surfaceHolder.lockCanvas();
 
                if (canvas != null) {
//                    Log.d(TAG, "W = " + canvas.getWidth() + " H = " + canvas.getHeight());
                    screen_width = canvas.getWidth();
                    screen_height = canvas.getHeight();
                    Log.d(TAG, "W = " + screen_width+ " H = " + screen_height );
                    surfaceHolder.unlockCanvasAndPost(canvas);
 
                    bmp2 = Bitmap.createBitmap(screen_width,  screen_height, Bitmap.Config.ARGB_8888);
                    canvas3 = new Canvas(bmp2);
                    canvas3.drawColor(Color.WHITE);
 
                    Log.d(TAG, "displaywidth W = " + display_width + "BMP H = " + bmp2.getHeight());
 
 
                    paint.setTextSize(30);
                    paint.setColor(Color.BLACK);
                    paint.setStrokeWidth(1.5f);
                    paint.setAntiAlias(true);
                    paint.setStyle(Paint.Style.STROKE);
 
                    holder.lockCanvas();
 
 
                    if (canvas != null){
 
 
                        canvas.drawBitmap(bmp2,0, 0, paint);
                        holder.unlockCanvasAndPost(canvas);
                    }
                }
            }
 
            @Override
            public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
 
            }
 
            @Override
            public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
 
            }
        });
 
 
 
        Log.i(TAG,String.format("当前线程号%d,json=%s",Thread.currentThread().getId(),"onCreateView"));
        url = getArguments().getString("arcgis_url");
        CThreadPoolExecutor.runInBackground(()->{
 
            readGisCar();
 
 
        });
        consumer.execute(new CalRunnable());
        scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
//                Log.i(TAG,"1s到");
                if (lastcount==count){
//                    Log.i(TAG,"已经没在发消息了");
                    leftDistance = 0.0;
                    rightDistance = 0.0;
                }
                lastcount = count;
            }
        },1000,1000, TimeUnit.MILLISECONDS);
 
        setupMap();
 
 
//        addTrailheadsLayer();
        url = Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator+_mActivity.getPackageName()+"/shoufei0223.mmpk";
        Log.i(TAG,"url ========="+url);
        final MobileMapPackage mobileMapPackage = new MobileMapPackage(url);
        mobileMapPackage.loadAsync();
        mobileMapPackage.addDoneLoadingListener(()->{
            LoadStatus loadStatus = mobileMapPackage.getLoadStatus();
            if (loadStatus==LoadStatus.LOADED){
                List<ArcGISMap> mainArcGisMapL = mobileMapPackage.getMaps();
                ArcGISMap mainArcGismapMMPK = mainArcGisMapL.get(0);
                mMapView.setMap(mainArcGismapMMPK);
            }
        });
        return view;
    }
 
 
 
    RTKInfoBean rtkInfoBean;
    boolean flag = true;
 
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_change_map:
                if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){
                    RoadDriveMapFragmentab jiaXiaoFragment = findFragment(RoadDriveMapFragmentab.class);
                    if (jiaXiaoFragment == null) {
                        jiaXiaoFragment = (RoadDriveMapFragmentab) RoadDriveMapFragmentab.newInstance();
                    }
                    startWithPop(jiaXiaoFragment);
                }else{
                    MapFragment jiaXiaoFragment = findFragment(MapFragment.class);
                    if (jiaXiaoFragment == null) {
                        jiaXiaoFragment = (MapFragment) MapFragment.newInstance();
                    }
                    startWithPop(jiaXiaoFragment);
                }
 
 
                break;
        }
    }
    private String osdHeading = null;
    private String osdRtkSpeed = null;
    private  List<Integer> body = new ArrayList<>();
    private  List<Integer> tire = new ArrayList<>();
    int line = 0;
    double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533}
            , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}};
    class CalRunnable implements Runnable{
        private String json;
        private int cmd;
        @Override
        public void run() {
            while (flag){
 
                MessageRemoteService messageRemoteService = (MessageRemoteService) queue1.peek();
                if (messageRemoteService == null){
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                messageRemoteService = (MessageRemoteService) queue1.poll();
                if (messageRemoteService != null) {
                    this.cmd = messageRemoteService.msgCode;
                    this.json = messageRemoteService.json;
                    MyLog.i(TAG, json);
 
 
                    RealTimeCarPos timeCarPos = gson.fromJson((String) json, RealTimeCarPos.class);
                    List<Double> points = timeCarPos.getPoint();
                    switch (timeCarPos.getMove()) {
                        case 0:
                            osdMoveDirect = "停车";
                            break;
                        case 1:
                            osdMoveDirect = "前进";
                            break;
                        case -1:
                            osdMoveDirect = "后退";
                            break;
                    }
                    osdHeading = "方向角" + String.valueOf(timeCarPos.getHeading());
 
                    BigDecimal bd = new BigDecimal(timeCarPos.getSpeed());
                    bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP);
                    osdRtkSpeed = "速度:" + bd;
 
 
                    line = 0;
 
 
 
 
                    car = new double[points.size() / 2][2];
 
                    for (int i = 0; i < points.size(); i++) {
                        if ((i % 2) == 0) {
                            car[line][0] = points.get(i);
                        } else {
                            double value = points.get(i);
                            car[line][1] = value;
                            line++;
                        }
 
                    }
 
                    List<Double> mainAnt = timeCarPos.getMain_ant();
                    List<Integer> tire1 = timeCarPos.getLeft_front_tire();
                    List<Integer> tire2 = timeCarPos.getRight_front_tire();
                    List<Integer> tire3 = timeCarPos.getLeft_rear_tire();
                    List<Integer> tire4 = timeCarPos.getRight_rear_tire();
 
                    body = timeCarPos.getBody();
 
                    tire = new ArrayList<>();
 
                    double yaw = timeCarPos.getHeading();
 
                    tire.add(tire1.get(0));
                    tire.add(tire2.get(0));
                    tire.add(tire3.get(0));
                    tire.add(tire4.get(0));
 
 
                }
 
 
 
 
 
 
 
 
 
 
 
//                rtkInfoBean = (RTKInfoBean)queue.peek();
//                if (rtkInfoBean ==null){
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
                rtkInfoBean = (RTKInfoBean)queue.poll();
                if (rtkInfoBean != null){
                    Log.i(TAG,String.format("取出一个,queue.size=%d,rtkinfo=%s,线程号=%d",queue.size(),rtkInfoBean.toString(),Thread.currentThread().getId()));
                    yaw = rtkInfoBean.getHeading();
                    startX = rtkInfoBean.getCoord_y();
                    startY = rtkInfoBean.getCoord_x();
                    osdHeading="方向角"+String.valueOf(rtkInfoBean.getHeading());
 
 
 
 
 
                    if (mMapView != null){
                        mMapView.setViewpointRotationAsync(rtkInfoBean.getHeading());
                    }
                addGraphicLayer(yaw,startX,startY);
 
 
 
                }
 
            }
 
        }
    }
    float base_x = 300;
    float base_y = 20;
    long scale_x,scale_y;
    double min_x=0.0,min_y = 0;
    private String osdMoveDirect = null;
    private void drawRightPart() {
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
 
        canvas3.drawColor(Color.YELLOW);
 
 
 
if (gisCarModel != null){
    PointF mainPoint = new PointF(startX, startY);
 
 
 
    for (int i = 0; i < car.length; i++) {
        PointF oldPoint = new PointF(car[i][0], car[i][1]);
        PointF newPoint = rotatePoint(oldPoint, mainPoint, yaw );
        car[i][0] = newPoint.getX();
        car[i][1] = newPoint.getY();
 
        car[i][0] = car[i][0] - mainPoint.getX();
        car[i][1] = car[i][1] - mainPoint.getY();
        car[i][1] = -car[i][1];
    }
 
}
 
 
 
        // 指南针 ++++++++++++++++++++++++++++++++++++++++++++++++++++
        float compassOX = bmp2.getWidth() - 60, compassOY = 60;
        Log.i(TAG,"draw widht="+(bmp2.getWidth() - 60));
        float compass1X = compassOX + 7, compass1Y = compassOY;
        float compass2X = compassOX, compass2Y = compassOY + 30;
        float compass3X = compassOX - 7, compass3Y = compassOY;
 
        float compass4X = compassOX + 7, compass4Y = compassOY;
        float compass5X = compassOX, compass5Y = compassOY - 30;
        float compass6X = compassOX - 7, compass6Y = compassOY;
 
        PointF compassO = new PointF(compassOX, compassOY);
        PointF compass1 = new PointF(compass1X, compass1Y);
        PointF compass2 = new PointF(compass2X, compass2Y);
        PointF compass3 = new PointF(compass3X, compass3Y);
        PointF compass4 = new PointF(compass4X, compass4Y);
        PointF compass5 = new PointF(compass5X, compass5Y);
        PointF compass6 = new PointF(compass6X, compass6Y);
 
        compass1 = rotatePoint(compass1, compassO, yaw);
        compass2 = rotatePoint(compass2, compassO, yaw);
        compass3 = rotatePoint(compass3, compassO, yaw);
        compass4 = rotatePoint(compass4, compassO, yaw);
        compass5 = rotatePoint(compass5, compassO, yaw);
        compass6 = rotatePoint(compass6, compassO, yaw);
 
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.RED);
 
        canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 20, paint);
        canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 40, paint);
 
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setColor(Color.BLUE);
        Path compassN = new Path();
 
        compassN.moveTo((float)compassO.getX(), (float)compassO.getY());
        compassN.lineTo((float)compass1.getX(), (float)compass1.getY());
        compassN.lineTo((float)compass2.getX(), (float)compass2.getY());
        compassN.lineTo((float)compass3.getX(), (float)compass3.getY());
        compassN.close();
        canvas3.drawPath(compassN, paint);
 
        paint.setColor(Color.RED);
        Path compassS = new Path();
        compassS.moveTo((float)compassO.getX(), (float)compassO.getY());
        compassS.lineTo((float)compass4.getX(), (float)compass4.getY());
        compassS.lineTo((float)compass5.getX(), (float)compass5.getY());
        compassS.lineTo((float)compass6.getX(), (float)compass6.getY());
        compassS.close();
        canvas3.drawPath(compassS, paint);
        // 指南针 -------------------------------------------
 
 
        if (osdHeading != null) {
            Path pathText = new Path();
            pathText.moveTo(10, 30);
            pathText.lineTo(700, 30);
            canvas3.drawTextOnPath(osdHeading, pathText, 0, 0, paint);//逆时针生成
        }
 
 
        if (osdRtkSpeed != null) {
            Path pathText = new Path();
            pathText.moveTo(10, 70);
            pathText.lineTo(700, 70);
            canvas3.drawTextOnPath(osdRtkSpeed, pathText, 0, 0, paint);//逆时针生成
        }
 
 
 
 
        base_x = 170;
        base_y = 350;
 
        scale_x=scale_y = 27;
 
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setColor(Color.BLUE);
//        canvas2.drawCircle((float) (base_x + (mainAnt.get(0) - min_x) * scale_x), (float) (base_y + (mainAnt.get(1) - min_y) * scale_y), 2, paint);
        canvas3.drawCircle((float) base_x, (float) base_y, 2, paint);
 
        if (gisCarModel != null&&car.length>0 && tire.size()>0){
            paint.setColor(Color.RED);
            Log.i(TAG,String.format("scalex=%d,scaley=%d,car[0][0]=%f,base_x=%f,base_y=%f",scale_x,scale_y,car[tire.get(0)][0],base_x,base_y));
            canvas3.drawCircle((float) (base_x + (car[tire.get(0)][0]) * scale_x), (float) (base_y + (car[tire.get(0)][1]) * scale_y), 2.5f, paint);
            canvas3.drawCircle((float) (base_x + (car[tire.get(1)][0]) * scale_x), (float) (base_y + (car[tire.get(1)][1]) * scale_y), 2.5f, paint);
            canvas3.drawCircle((float) (base_x + (car[tire.get(2)][0]) * scale_x), (float) (base_y + (car[tire.get(2)][1]) * scale_y), 2.5f, paint);
            canvas3.drawCircle((float) (base_x + (car[tire.get(3)][0]) * scale_x), (float) (base_y + (car[tire.get(3)][1]) * scale_y), 2.5f, paint);
 
 
 
            Path pathCanvs3 = new Path();
            pathCanvs3.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y));
            for (int i = 1; i < body.size(); i++){
//                    Log.d(TAG, "for 循环 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y));
                Log.i(TAG,String.format("car[%d][0]=%f,to X =%f,car[%d][1]=%f,to Y=%f",i,car[body.get(i)][0],
                        (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x),i,car[body.get(i)][1],(float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)));
                pathCanvs3.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y));
            }
            paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.BLACK);
            pathCanvs3.close();
            canvas3.drawPath(pathCanvs3,paint);
        }
 
 
        Paint mPaint = new Paint();
        mPaint.setTextSize(20);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        osdMoveDirect="9.4345";
        if (osdMoveDirect != null) {
            Path pathText = new Path();
            pathText.moveTo(base_x-110, base_y-35);
            pathText.lineTo(base_x-20, base_y-35);
            if (leftDistance == 0.0){
 
                canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//逆时针生成
            }else{
 
                canvas3.drawTextOnPath(String.valueOf(leftDistance), pathText, 0, 0, mPaint);//逆时针生成
            }
        }
        if (osdMoveDirect != null) {
            Path pathText = new Path();
            pathText.moveTo(base_x+30, base_y-35);
            pathText.lineTo(base_x+110, base_y-35);
            if (rightDistance == 0.0){
 
                canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//逆时针生成
            }else{
                canvas3.drawTextOnPath(String.valueOf(rightDistance), pathText, 0, 0, mPaint);//逆时针生成
            }
 
        }
        paint.setColor(Color.RED);
        canvas3.drawLine(base_x-120,base_y-200,base_x-120,base_y+200,paint);
        canvas3.drawLine(base_x+120,base_y-200,base_x+120,base_y+200,paint);
 
        DrawArrows(canvas3,Color.GREEN,15f,base_x-20,base_y-30,base_x-120,base_y-30);//左边箭头(左边距
        DrawArrows(canvas3,Color.GREEN,15f,base_x+20,base_y-30,base_x+120,base_y-30);//右边箭头(边距
 
 
        // 提交画布
        Canvas canvas = holder.lockCanvas();
        if (canvas != null){
 
 
            canvas.drawBitmap(bmp2,0, 0, paint);
            holder.unlockCanvasAndPost(canvas);
        }
    }
    void DrawArrows(Canvas canvas, int color, float arrowSize, float x1,
                    float y1, float x2, float y2) {
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(color);
 
        // 画直线
        canvas.drawLine(x1, y1, x2, y2, paint);
 
        // 箭头中的第一条线的起点
        int x3 = 0;
        int y3 = 0;
 
        // 箭头中的第二条线的起点
        int x4 = 0;
        int y4 = 0;
 
        double awrad = Math.atan(3.5 / 8);
        double[] arrXY_1 = rotateVec(x2 - x1, y2 - y1, awrad, arrowSize);
        double[] arrXY_2 = rotateVec(x2 - x1, y2 - y1, -awrad, arrowSize);
 
        // 第一端点
        Double X3 = Double.valueOf(x2 - arrXY_1[0]);
        x3 = X3.intValue();
        Double Y3 = Double.valueOf(y2 - arrXY_1[1]);
        y3 = Y3.intValue();
 
        // 第二端点
        Double X4 = Double.valueOf(x2 - arrXY_2[0]);
        x4 = X4.intValue();
        Double Y4 = Double.valueOf(y2 - arrXY_2[1]);
        y4 = Y4.intValue();
 
        Path arrowsPath = new Path();
        arrowsPath.moveTo(x2, y2);
        arrowsPath.lineTo(x3, y3);
        arrowsPath.lineTo(x4, y4);
        arrowsPath.close();
        canvas.drawLine(x3, y3, x2, y2, paint);
        canvas.drawLine(x4, y4, x2, y2, paint);
    }
    private double[] rotateVec(float px, float py, double ang, double arrowSize) {
        double mathstr[] = new double[2];
        double vx = px * Math.cos(ang) - py * Math.sin(ang);
        double vy = px * Math.sin(ang) + py * Math.cos(ang);
        double d = Math.sqrt(vx * vx + vy * vy);
        vx = vx / d * arrowSize;
        vy = vy / d * arrowSize;
        mathstr[0] = vx;
        mathstr[1] = vy;
        return mathstr;
    }
 
    public PointF rotatePoint(PointF oldPoint, PointF centre, double degree) {
        PointF newPoint = new PointF(0, 0);
 
        newPoint.setX( (oldPoint.getX()-centre.getX())*Math.cos(Math.toRadians(degree)) - (oldPoint.getY()-centre.getY())*Math.sin(Math.toRadians(degree)) + centre.getX() );
        newPoint.setY ( (oldPoint.getX()-centre.getX())*Math.sin(Math.toRadians(degree)) + (oldPoint.getY()-centre.getY())*Math.cos(Math.toRadians(degree)) + centre.getY() );
 
        return newPoint;
    }
 
    class PointF {
        double x;
        double y;
 
        public PointF(double x, double y) {
            this.x = x;
            this.y = y;
        }
 
        double getX() {
            return x;
        }
 
        double getY() {
            return y;
        }
 
        void setX(double x) {
            this.x = x;
        }
 
        void setY(double y) {
            this.y = y;
        }
    }
    private void setupMap() {
        if (mMapView != null) {
 
 
            mGraphicsOverlay = addGraphicsOverlay(mMapView);
 
        }
    }
String url ;
    private void addTrailheadsLayer() {
        if (!TextUtils.isEmpty(url)){
            Log.i(TAG,"map_url="+url);
            final ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(url);
            // create an empty map instance
            ArcGISMap map = new ArcGISMap();
            Log.i(TAG,String.format("map.getMiniScale=%f",map.getMinScale()));
            map.setMinScale(300.0);
            // add map image layer as operational layer
            map.getOperationalLayers().add(mapImageLayer);
            mMapView.setMap(map);
        }else{
            Toast.makeText(_mActivity, "url为空", Toast.LENGTH_SHORT).show();
        }
 
 
 
    }
 
 
 
    GisCarModel gisCarModel;
    boolean once =true;
    private void addGraphicLayer(double yaw,double x,double y){
        Log.i(TAG,"addgraphicLayer开始");
        long time = System.currentTimeMillis();
 
 
 
        if (gisCarModel != null){
 
 
            long  qudianTime = System.currentTimeMillis();
            List<safeluck.drive.evaluation.bean.Point> carNew =Utils.getCarPoint(0,yaw,new safeluck.drive.evaluation.bean.Point(x,y),gisCarModel);
            Log.i(TAG,String.format("取到点耗时=%d毫秒,线程号=%d",System.currentTimeMillis()-qudianTime,Thread.currentThread().getId()));
            if (carNew == null) return;
            if (once){
                Message message = Message.obtain();
                message.what = MSG_CAR;
 
                message.obj = carNew;
                mHandler.sendMessage(message);
 
            }
 
 
 
 
 
 
        }
 
 
        long period= System.currentTimeMillis()-time;
        Log.i(TAG,"执行addGraphicLayer方法,耗时="+period);
 
 
 
    }
 
    private GraphicsOverlay addGraphicsOverlay(MapView mapView){
        //create the graphics overlay
        GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
        mGraphicsOverlay_body = new GraphicsOverlay();
        //add the overlay to the map view
        mapView.getGraphicsOverlays().add(mGraphicsOverlay_body);
        mapView.getGraphicsOverlays().add(graphicsOverlay);
        return graphicsOverlay;
    }
    private void readGisCar() {
 
        String carFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+_mActivity.getPackageName()+"/gisvehiclemodel.json";
        if (TextUtils.isEmpty(carFilePath)){
            Toast.makeText(_mActivity, "车辆模型文件不存在", Toast.LENGTH_SHORT).show();
            MyLog.i (TAG, "GISCar车辆模型文件不存在");
            return ;
        }
        byte[] fileContentBytes= FileUtil.readFile(carFilePath);
        if (fileContentBytes !=null&&fileContentBytes.length>0){
            String buffer= new String(fileContentBytes);
            gisCarModel = new Gson().fromJson(buffer, GisCarModel.class);
 
 
 
//            line = 0;
//
//
//            List<Double> points = gisCarModel.getPoint();
//
//            car = new double[points.size() / 2][2];
//
//            for (int i = 0; i < points.size(); i++) {
//                if ((i % 2) == 0) {
//                    car[line][0] = points.get(i);
//                } else {
//                    double value = points.get(i);
//                    car[line][1] = value;
//                    line++;
//                }
//
//            }
//
//
//            List<Integer> tire1 = gisCarModel.getLeft_front_tire();
//            List<Integer> tire2 = gisCarModel.getRight_front_tire();
//            List<Integer> tire3 = gisCarModel.getLeft_rear_tire();
//            List<Integer> tire4 = gisCarModel.getRight_rear_tire();
//
//            body = gisCarModel.getBody();
//
//            tire = new ArrayList<>();
//
//
//            tire.add(tire1.get(0));
//            tire.add(tire2.get(0));
//            tire.add(tire3.get(0));
//            tire.add(tire4.get(0));
        }else{
            return;
        }
 
 
    }
 
 
 
    PointCollection points1 = new PointCollection(SpatialReference.create(4544));
    PointCollection points2 = new PointCollection(SpatialReference.create(4544));
    PointCollection points3 = new PointCollection(SpatialReference.create(4544));
    PointCollection points4 = new PointCollection(SpatialReference.create(4544));
    SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.rgb(232,0,0), 0.5f);
    SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,232,0,0), lineSymbol);
 
    SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.WHITE, 5);
    SimpleFillSymbol simpleFillSymbolGls = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,0,0,0), lineSymbolGls);
    private void drawGlses(List<safeluck.drive.evaluation.bean.Point> carNew,  GisCarModel gisCarModel) {
 
        if(gisCarModel== null){
            return;
        }
 
        long beginTime = System.currentTimeMillis();
 
 
/**==============================car body=========================================*/
 
        List<Integer> bodys =gisCarModel.getBody();
        points.clear();
        for (int i = 0; i <bodys.size(); i++) {
            points.add(carNew.get(bodys.get(i)).getX(),carNew.get(bodys.get(i)).getY());
        }
 
        Polygon polygon = new Polygon(points);
 
        Graphic graphic = new Graphic(polygon,simpleFillSymbol);
 
 
 
        /**===============================car body end========================================*/
 
 
/**==============================画天线=========================================*/
 
 
//        Graphic graphicAnt = new Graphic(new Point(startX,startY), simpleMarkerSymbol);
 
        /**==============================画天线结束 END=========================================*/
 
 
 
        List<Integer> leftCenterGls = gisCarModel.getLeft_center_glass();
        points1.clear();
        for (int i = 0; i < leftCenterGls.size(); i++) {
            int pos = leftCenterGls.get(i);
            points1.add(carNew.get(pos).getX(), carNew.get(pos).getY());
 
        }
        List<Integer> rightCenterGls = gisCarModel.getRight_center_glass();
        points2.clear();
        for (int i = 0; i < leftCenterGls.size(); i++) {
            int pos = rightCenterGls.get(i);
            points2.add(carNew.get(pos).getX(), carNew.get(pos).getY());
 
        }
 
 
                List<Integer> frontCLs = new ArrayList<>();
        frontCLs.addAll(gisCarModel.getLeft_front_glass());
        frontCLs.addAll(gisCarModel.getRight_front_glass());
 
 
        points3.clear();
        for (int i = 0; i < frontCLs.size(); i++) {
            int pos = frontCLs.get(i);
            points3.add(carNew.get(pos).getX(), carNew.get(pos).getY());
 
        }
                frontCLs.clear();
        frontCLs.addAll(gisCarModel.getLeft_rear_glass());
        frontCLs.addAll(gisCarModel.getRight_rear_glass());
        points4.clear();
        for (int i = 0; i < frontCLs.size(); i++) {
            int pos = frontCLs.get(i);
            points4.add(carNew.get(pos).getX(), carNew.get(pos).getY());
 
        }
        Polygon polygon1 = new Polygon(points1);
        Polygon polygon2 = new Polygon(points2);
        Polygon polygon3 = new Polygon(points3);
        Polygon polygon4 = new Polygon(points4);
 
 
        //create graphics
 
        Graphic buoyGraphic1 = new Graphic(polygon1, simpleFillSymbolGls);
        Graphic buoyGraphic2 = new Graphic(polygon2, simpleFillSymbolGls);
        Graphic buoyGraphic3 = new Graphic(polygon3, simpleFillSymbolGls);
        Graphic buoyGraphic4 = new Graphic(polygon4, simpleFillSymbolGls);
        //add the graphics to the graphics overlay
        /**==============================清除GraphicsOverlay上所有graphic=========================================*/
        long clearTime = System.currentTimeMillis();
 
 
        mGraphicsOverlay.getGraphics().clear();
        Log.i(TAG,"clear方法时间+"+(System.currentTimeMillis()-clearTime));
        /**==============================清除GraphicsOverlay上所有graphic   END=========================================*/
 
        mGraphicsOverlay.getGraphics().add(buoyGraphic1);
        mGraphicsOverlay.getGraphics().add(buoyGraphic2);
        mGraphicsOverlay.getGraphics().add(buoyGraphic3);
        mGraphicsOverlay.getGraphics().add(buoyGraphic4);
        mGraphicsOverlay_body.getGraphics().clear();
        mGraphicsOverlay_body.getGraphics().add(graphic);
//        mGraphicsOverlay.getGraphics().add(graphicAnt);
        Log.i(TAG,"GraphicsOverLay add graphic完成"+(System.currentTimeMillis()-beginTime));
        if (mMapView != null){
            mMapView.setViewpointCenterAsync(new Point(startX,startY));
        }
 
 
 
 
    }
 
    /**
     * 绘制面
     */
    private void drawPolygon() {
//        List<Point> points = new ArrayList<>();
//        points.add(new Point(21.21,21.32, SpatialReference.create("4544")));
//        PointCollection pointCollection = new PointCollection(points);
 
        mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) {
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
 
                mGraphicsOverlay.getGraphics().clear();
                Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())));
                mPointCollection.add(point);
 
                Polygon polygon = new Polygon(mPointCollection);
 
                if (mPointCollection.size() == 1) {
                    SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
                    Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol);
                    mGraphicsOverlay.getGraphics().add(pointGraphic);
                }
 
                SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GREEN, 3.0f);
                SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.parseColor("#33e97676"), lineSymbol);
                Graphic graphic = new Graphic(polygon, simpleFillSymbol);
                mGraphicsOverlay.getGraphics().add(graphic);
 
                return super.onSingleTapConfirmed(e);
            }
        });
    }
 
    /**
     * 绘制点
     */
    private void drawPoint() {
        mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) {
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                Point clickPoint = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())));
                SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 20);
                Graphic graphic = new Graphic(clickPoint, simpleMarkerSymbol);
                //清除上一个点
                mGraphicsOverlay.getGraphics().clear();
                mGraphicsOverlay.getGraphics().add(graphic);
 
                //使用渲染器
                //                Graphic graphic1 = new Graphic(clickPoint);
                //                SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol);
                //                mGraphicsOverlay.setRenderer(simpleRenderer);
                //                mGraphicsOverlay.getGraphics().clear();
                //                mGraphicsOverlay.getGraphics().add(graphic1);
 
                return super.onSingleTapConfirmed(e);
            }
        });
    }
 
    /**
     * 绘制线
     */
    private void drawPolyline() {
        mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(_mActivity, mMapView) {
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                Point point = mMapView.screenToLocation(new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())));
                mPointCollection.add(point);
 
                Polyline polyline = new Polyline(mPointCollection);
 
                //点
                SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
                Graphic pointGraphic = new Graphic(point, simpleMarkerSymbol);
                mGraphicsOverlay.getGraphics().add(pointGraphic);
 
                //线
                SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.parseColor("#FC8145"), 3);
                Graphic graphic = new Graphic(polyline, simpleLineSymbol);
                mGraphicsOverlay.getGraphics().add(graphic);
 
                return super.onSingleTapConfirmed(e);
            }
        });
    }
 
 
 
    @Override
    public void onPause() {
        if (mMapView != null) {
            mMapView.pause();
        }
        super.onPause();
    }
 
    @Override
    public void onResume() {
        super.onResume();
        if (mMapView != null) {
            mMapView.resume();
        }
    }
 
    @Override
    public void onDetach() {
        super.onDetach();
        if (mMapView != null) {
            mMapView.dispose();
        }
        Log.i(TAG,"清空队列");
        flag = false;
        producer.shutdown();
        consumer .shutdown();
        queue.clear();
        CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_RTK_INFO_MAP);
        CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_EXAM_STATUS_TOPIC);
        CEventCenter.onBindEvent(false, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
        CEventCenter.onBindEvent(false, icEventListenerCar, Constant.REAL_TIME_POS_CAR_TOPIC);
 
 
    }
 
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTK_INFO_MAP);
        CEventCenter.onBindEvent(true,icEventListener1,Constant.BIND_EXAM_STATUS_TOPIC);
        CEventCenter.onBindEvent(true, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
        CEventCenter.onBindEvent(true, icEventListenerCar, Constant.REAL_TIME_POS_CAR_TOPIC);
    }
 
    private long count =0;
    private long lastcount =0;
    private double gpsSpeed = 0;
    private double leftDistance = 0;
    private double rightDistance = 0;
    private ICEventListener speedListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode == Constant.RTK_INFO){
                gpsSpeed = (double)obj;
            }
            if (msgCode == Constant.LEFT_RIGHT_DISTANCE){
                String str = (String)obj;
                count++;
 
                try {
                    JSONObject jsonObject = new JSONObject(str);
                    leftDistance = Utils.getdouble(jsonObject.getDouble("left"),3);
                    rightDistance = Utils.getdouble(jsonObject.getDouble("right"),3);
 
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    class MessageRemoteService{
        public int msgCode;
        public String json;
 
        public MessageRemoteService(int msgCode, Object obj) {
            this.json = (String) obj;
            this.msgCode = msgCode;
        }
    }
 
    private ICEventListener icEventListenerCar = new ICEventListener() {
        @Override
        public void onCEvent(String topic, final int msgCode, int resultCode, final Object obj) {
 
 
            producer.execute(new Runnable() {
                @Override
                public void run() {
                    queue1.offer(new MessageRemoteService(msgCode,obj));
                }
            });
 
 
        }
    };
}