From e42e72f0f470b7c1d8a195745d9ea476c0c38ec8 Mon Sep 17 00:00:00 2001
From: Admin <Dana_Lee1016@126.com>
Date: 星期六, 20 二月 2021 15:47:50 +0800
Subject: [PATCH] arcgis 增加距离显示

---
 app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java |  552 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 549 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java
index 466512f..8d62c10 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/ArcGisMapFragment.java
@@ -1,7 +1,12 @@
 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;
@@ -11,6 +16,8 @@
 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;
@@ -36,11 +43,17 @@
 import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
 import com.google.gson.Gson;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
+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;
@@ -51,6 +64,7 @@
 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;
@@ -69,6 +83,7 @@
     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);
@@ -114,6 +129,8 @@
             }
         }
     };
+    private SurfaceView mSurfaceView;
+    private SurfaceHolder holder;
 
     public static SupportFragment newInstance(String s){
         ArcGisMapFragment jiaXiaoFragment = new ArcGisMapFragment();
@@ -140,13 +157,19 @@
                     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) {
@@ -155,6 +178,60 @@
         View view = inflater.inflate(R.layout.layout_arc_gis,container,false);
         mMapView = view.findViewById(R.id.mapView);
         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(()->{
@@ -164,6 +241,18 @@
 
         });
         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();
 
@@ -199,20 +288,122 @@
                 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());
@@ -227,14 +418,277 @@
 
         }
     }
+    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){
+            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) {
 
@@ -324,6 +778,42 @@
         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;
         }
@@ -347,6 +837,7 @@
         if(gisCarModel== null){
             return;
         }
+
         long beginTime = System.currentTimeMillis();
 
 
@@ -568,6 +1059,8 @@
         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);
 
 
     }
@@ -577,6 +1070,59 @@
         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));
+                }
+            });
+
+
+        }
+    };
 }

--
Gitblit v1.8.0