From a4a126cc414793a3c06da7c1f80f50131fe05792 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期五, 20 三月 2020 15:43:01 +0800
Subject: [PATCH] 提交路考地图

---
 app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java |  375 +++++++++++++++++++++++++++++++++-------
 app/src/main/res/layout/layout_net_train.xml                                   |    4 
 app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java        |    3 
 app/src/main/java/safeluck/drive/evaluation/util/Utils.java                    |    6 
 app/src/main/java/safeluck/drive/evaluation/bean/RoadExamMap.java              |   43 +++-
 app/src/main/assets/roadmap.json                                               |   67 ++++++-
 6 files changed, 397 insertions(+), 101 deletions(-)

diff --git a/app/src/main/assets/roadmap.json b/app/src/main/assets/roadmap.json
index 1504d68..3322f6e 100644
--- a/app/src/main/assets/roadmap.json
+++ b/app/src/main/assets/roadmap.json
@@ -1,11 +1,58 @@
-[{
-  "id": 863,
-  "item": 1,
-  "point": [{
-    "x-y": [1,5,2,5,3,5,4,5,5,5,6,5,6,6,7,6,7,5,8,5,9,5,10,5,11,5,12,5,12,3,11,3,10,3,9,3,8,3,7,3,6,3,5,3,4,3,3,3,2,3,1,3
+{
+  "points": [0, 1, 1.6, 1, 2.55, 1, 3.05, 1, 4.55, 1, 5.003, 1, 6.003, 1, 9.003, 1, 9.003, 4, 0, 0.5, 9.003, 0.5, 0, 0, 1.6, 0, 2.55, 0, 3.05, 0, 4.55, 0, 5.003, 0, 5.003, -2, 5.003, -3, 5.003, -4, 6.003, -4, 7.003, -4, 9.003, -4, 10.003, -4, 10.003, -3, 10.003, 4, 6.003, 0, 9.003, 0, 6.003, 0, 6.003, -3, 9.003, -3, 9.003, 0, 5.503, 0, 5.503, -2, 5.503, -3.5, 7.003, -3.5, 9.503, -3.5, 9.503, 4, 1.6, 1, 1.6, 0, 2.55, 1, 2.55, 0, 3.05, 0, 3.05, 1, 4.55, 1, 4.55, 0, 5.003, 1, 5.003, 0, 6.003, 0, 6.003, 1, 6.003, -2, 5.003, -2, 6.003, -3, 5.003, -3, 5.003, -4, 6.003, -4, 9.003, -1, 10.003, -1, 9.003, 0, 10.003, 0, 10.003, 1, 9.003, 1],
+  "maps": [{
+    "id": 1005,
+    "item": 100,
+    "red_line": [
+      [0, 1, 2, 3, 4, 5, 6, 7, 8],
+      [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],
+      [26, 27],
+      [28, 29, 30, 31]
+    ],
+    "green_line": [
+      [9, 10],
+      [32, 33, 34, 35, 36, 37]
+    ],
+    "all_trigger_line": [
+      [1002, 38, 39],
+      [1003, 44, 45],
+      [1004, 56, 57],
+      [1005, 50, 51]
+    ],
+    "red_area": [
+      [40, 41, 42, 43]
     ]
-  }
-  ]
-
-  }
-]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
\ No newline at end of file
+  }, {
+    "id": 1003,
+    "item": 106,
+    "tts": "鍓嶆柟鍙宠浆",
+    "stop_line": [46, 47],
+    "area": [44,45,48, 49],
+    "red_line": [
+      [6, 26]
+    ],
+    "stop_flag": 0
+  }, {
+    "id": 1002,
+    "item": 107,
+    "tts": "鍓嶆柟閫氳繃浜鸿妯亾",
+    "stop_line": [40, 41],
+    "area": [38,39,42,43],
+    "stop_flag": 0
+  }, {
+    "id": 1004,
+    "item": 104,
+    "tts": "鐩磋閫氳繃璺彛",
+    "stop_line": [58, 59],
+    "area": [56,57,60,61],
+    "stop_flag": 0
+  }, {
+    "id": 1005,
+    "item": 105,
+    "tts": "鍓嶆柟宸﹁浆寮�",
+    "stop_line": [52, 53],
+    "end_line": [54, 55],
+    "area": [50,51,54,55],
+    "stop_flag": 0
+  }]
+}
\ No newline at end of file
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/RoadExamMap.java b/app/src/main/java/safeluck/drive/evaluation/bean/RoadExamMap.java
index 61e93b4..88fefc3 100644
--- a/app/src/main/java/safeluck/drive/evaluation/bean/RoadExamMap.java
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/RoadExamMap.java
@@ -4,6 +4,7 @@
 
 public class RoadExamMap {
 
+
     private List<Double> points;
     private List<MapsBean> maps;
 
@@ -27,14 +28,15 @@
         /**
          * id : 1005
          * item : 100
-         * red_line : [[1,2,3],[1,2,3]]
-         * green_line : [[1,2,3],[1,2,3]]
-         * trigger_line : [[1,2,3],[1,2,3]]
-         * red_area : [[2,3,4,5],[2,3,4,5]]
+         * red_line : [[0,1,2,3,4,5,6,7,8],[11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],[26,27],[28,29,30,31]]
+         * green_line : [[9,10],[32,33,34,35,36,37]]
+         * all_trigger_line : [[1002,38,39],[1003,44,45],[1004,56,57],[1005,50,51]]
+         * red_area : [[40,41,42,43]]
          * tts : 鍓嶆柟鍙宠浆
-         * start_line : [15,16]
-         * end_line : [22,23]
+         * stop_line : [46,47]
+         * area : [44,45,48,49]
          * stop_flag : 0
+         * end_line : [54,55]
          */
 
         private int id;
@@ -43,9 +45,10 @@
         private int stop_flag;
         private List<List<Integer>> red_line;
         private List<List<Integer>> green_line;
-        private List<List<Integer>> trigger_line;
+        private List<List<Integer>> all_trigger_line;
         private List<List<Integer>> red_area;
-        private List<Integer> start_line;
+        private List<Integer> stop_line;
+        private List<Integer> area;
         private List<Integer> end_line;
 
         public int getId() {
@@ -96,12 +99,12 @@
             this.green_line = green_line;
         }
 
-        public List<List<Integer>> getTrigger_line() {
-            return trigger_line;
+        public List<List<Integer>> getAll_trigger_line() {
+            return all_trigger_line;
         }
 
-        public void setTrigger_line(List<List<Integer>> trigger_line) {
-            this.trigger_line = trigger_line;
+        public void setAll_trigger_line(List<List<Integer>> all_trigger_line) {
+            this.all_trigger_line = all_trigger_line;
         }
 
         public List<List<Integer>> getRed_area() {
@@ -112,12 +115,20 @@
             this.red_area = red_area;
         }
 
-        public List<Integer> getStart_line() {
-            return start_line;
+        public List<Integer> getStop_line() {
+            return stop_line;
         }
 
-        public void setStart_line(List<Integer> start_line) {
-            this.start_line = start_line;
+        public void setStop_line(List<Integer> stop_line) {
+            this.stop_line = stop_line;
+        }
+
+        public List<Integer> getArea() {
+            return area;
+        }
+
+        public void setArea(List<Integer> area) {
+            this.area = area;
         }
 
         public List<Integer> getEnd_line() {
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
index 0843923..93bbeab 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
@@ -1,10 +1,14 @@
 package safeluck.drive.evaluation.fragment;
 
+import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Color;
+import android.graphics.DashPathEffect;
 import android.graphics.Paint;
 import android.graphics.Path;
+import android.graphics.PathEffect;
+import android.graphics.RectF;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -21,19 +25,28 @@
 import com.google.gson.reflect.TypeToken;
 
 import java.lang.reflect.Type;
+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 me.yokeyword.fragmentation.SupportFragment;
 import safeluck.drive.evaluation.Constant;
 import safeluck.drive.evaluation.bean.ExamMap;
+import safeluck.drive.evaluation.bean.RealTimeCarPos;
+import safeluck.drive.evaluation.bean.RoadExamMap;
+import safeluck.drive.evaluation.cEventCenter.CEventCenter;
+import safeluck.drive.evaluation.cEventCenter.ICEventListener;
 import safeluck.drive.evaluation.util.FileUtil;
+
+import static android.view.View.LAYER_TYPE_SOFTWARE;
 
 public class RoadDriveMapFragment extends SupportFragment implements SurfaceHolder.Callback {
 
     private static final String TAG = RoadDriveMapFragment.class.getSimpleName();
+    private static final int ALL_MAP = 100;//鎬诲浘
 
     private SurfaceView mSurfaceView;
     private SurfaceHolder mSurfaceHolder;
@@ -44,15 +57,47 @@
     private Path mPath;
     private StringBuffer buffer;//瀛樻斁鍦板浘鐨刡uffer
     private Gson gson = new Gson();
+    private double gpsSpeed = 0;
+    private int map_id = -1;
+
+
+    private String osdHeading = null;
+    private String osdMoveDirect = null;
+    private String osdRtkSpeed = null;
+    private String osdQf = null;
+    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}};
+    double map[][]={};
+
+    private LinkedBlockingQueue queue = new LinkedBlockingQueue(100);
 
     private int avaliableWidth,avaliableHeight;
 
     private int x = 50, y = 50, r = 10; // 鍦嗙殑鍧愭爣鍜屽崐寰�
-    private int sinx = 0,siny =0 ;
     float [] pts={50,100,100,200,200,300,300,400};
 
     private ExecutorService generateData = Executors.newSingleThreadExecutor();//浜х敓鏁版嵁锛堜富瑕佹槸杞﹁締鏁版嵁锛�
     private ExecutorService drawThread = Executors.newSingleThreadExecutor();//缁樺埗绾跨▼
+
+
+    /**
+     * 鎺ユ敹杩滅▼鏈嶅姟鍙戣繃鏉ョ殑杞﹁締浣嶇疆淇℃伅
+     */
+    private ICEventListener icEventListener = new ICEventListener() {
+        @Override
+        public void onCEvent(String topic, final int msgCode, int resultCode, final Object obj) {
+
+
+            generateData.execute(new Runnable() {
+                @Override
+                public void run() {
+                    queue.offer(new MessageRemoteService(msgCode,obj));
+                }
+            });
+
+
+        }
+    };
 
     public static RoadDriveMapFragment newInstance(){
         return new RoadDriveMapFragment();
@@ -103,6 +148,7 @@
 
 
         flag = true;
+
         drawThread.execute(new DrawRunnable());
     }
 
@@ -117,62 +163,123 @@
         flag = false;
     }
 
-    List<ExamMap> examMaps = new ArrayList<>();
+    RoadExamMap examMaps ;
+
     /**
      * 涓昏鏄繖涓柟娉曪紝杩涜鍧愭爣鐐硅绠楋紝浣跨敤mPath鐢诲浘锛屽彲鑳借鐢ㄥ埌Canvas
      * 鏈�濂藉彧浣跨敤path
      */
     private void calculate() {
-        int map_id = 863;
-        int map_line = 0;
-        double map[][]={};
+        int map_line = 0,line = 0;
+        MessageRemoteService messageRemoteService = (MessageRemoteService) queue.peek();
+        if (messageRemoteService == null){
+            Log.i(TAG,"messageRemoteService ==null");
 
-        if (buffer == null){
-
-            buffer = FileUtil.readAssetTxtFile(_mActivity, Constant.ROAD_MAP);
-            Log.i(TAG,"ditu="+buffer.toString().trim());
-        }
-        Type type = new TypeToken<List<ExamMap>>(){}.getType();
-        if (buffer != null){
-            examMaps= gson.fromJson(buffer.toString().trim(), type);
-        }
-
-        for (int i = 0; i < examMaps.size(); i++) {
-            ExamMap examMap = examMaps.get(i);
-            if (map_id == examMap.getId()){
-                List<ExamMap.PointBean> pointBeanList = examMap.getPoint();
-
-                for(int j=0; j<pointBeanList.size();j++){
-                    List<Double> xys = pointBeanList.get(j).getXy();
-                    if(j==0){
-                        map = new double[xys.size()/2][2];
-
-
-
-                        for (int k=0; k<xys.size();k++){
-                            if ((k % 2) == 0) {
-                                map[map_line][0] = xys.get(k);
-                                Log.i(TAG, "onCEvent: map鏂板��=" + map[map_line][0] + " 浣嶇疆锛�" + k);
-                            } else {
-                                double value = 0-xys.get(k);
-
-
-                                map[map_line][1] = value;
-                                map_line++;
-                            }
-                        }
-                    }else{
-                        MyLog.i(TAG,"鏆傛椂鏀寔鏇茬嚎");
-                        break;
-                    }
-
-
-
-                }
-                break;
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
             }
         }
-        onDrawMap(map);
+        messageRemoteService = (MessageRemoteService) queue.poll();
+        if (messageRemoteService != null){
+            MyLog.i(TAG, messageRemoteService.json);
+
+
+            RealTimeCarPos timeCarPos = gson.fromJson((String) messageRemoteService.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;
+
+            osdQf = "QF锛�" + String.valueOf(timeCarPos.getQf());
+
+
+
+            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 = 0 - points.get(i);
+                    car[line][1] = value;
+                    line++;
+                }
+
+            }
+            map_id = timeCarPos.getMap_id();
+
+            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();
+
+            List<Integer> body = timeCarPos.getBody();
+
+            List<Integer> tire = new ArrayList<>();
+
+            tire.add(tire1.get(0));
+            tire.add(tire2.get(0));
+            tire.add(tire3.get(0));
+            tire.add(tire4.get(0));
+
+
+
+
+            if (buffer == null){
+
+                buffer = FileUtil.readAssetTxtFile(_mActivity, Constant.ROAD_MAP);
+                Log.i(TAG,"ditu="+buffer.toString().trim());
+            }
+            Type type = new TypeToken<RoadExamMap>(){}.getType();
+            if (buffer != null){
+                examMaps= gson.fromJson(buffer.toString().trim(), type);
+            }
+            if (examMaps!=null){
+
+                points = examMaps.getPoints();
+                if (points != null){
+                    map = new double[points.size()/2][2];
+                    for (int i = 0; i < points.size(); i++) {
+                        if ((i % 2) == 0){
+                            map[map_line][0] = points.get(i);
+
+                        }else{
+                            double value = 0-points.get(i);
+                            map[map_line][1] = value;
+                            map_line++;
+                        }
+                    }
+                }
+            }
+
+            onDrawMap(map,examMaps.getMaps(),car,body,tire,mainAnt);
+
+        }
+
+
+
+
+
+
+
+
+
 //        mPaint.reset();
 //        mPaint.setStyle(Paint.Style.FILL);
 //        mPaint.setColor(Color.RED);
@@ -207,8 +314,8 @@
     }
 
 
-
-private void onDrawMap(final double map[][]){
+private void onDrawMap(final double[][] map, List<RoadExamMap.MapsBean> maps,final double[][] car,
+                       List<Integer>body, List<Integer> tire,List<Double> mainAnt){
     double base_x = 300, base_y = 20;
     double max_x = 0, min_x = 0, max_y = 0, min_y = 0;
 
@@ -235,6 +342,21 @@
             }
         }
     }
+    for (int i = 0; i < car.length; i++) {
+        if (max_x < car[i][0]) {
+            max_x = car[i][0];
+        }
+        if (min_x > car[i][0]) {
+            min_x = car[i][0];
+        }
+        if (max_y < car[i][1]) {
+            max_y = car[i][1];
+        }
+        if (min_y > car[i][1]) {
+            min_y = car[i][1];
+        }
+    }
+
     long scale_x = Math.round((mCanvas.getWidth() - base_x - 10) / (max_x - min_x));
     long scale_y = Math.round((mCanvas.getHeight() - base_y - 10) / (max_y - min_y));
 
@@ -246,31 +368,108 @@
 
     mPaint.reset();
     mPaint.setAntiAlias(true);
-    mPaint.setColor(Color.BLACK);
-    mPaint.setStyle(Paint.Style.STROKE);
+    mPaint.setColor(Color.BLUE);
     mPaint.setStrokeWidth(1.5f);
 
+    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
 
+    mCanvas.drawCircle((float) (base_x + (mainAnt.get(0) - min_x) * scale_x), (float) (base_y + (0 - mainAnt.get(1) - min_y) * scale_y), 2, mPaint);
+
+    mPaint.setColor(Color.RED);
+    mCanvas.drawCircle((float) (base_x + (car[tire.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(0)][1] - min_y) * scale_y), 2.5f, mPaint);
+    mCanvas.drawCircle((float) (base_x + (car[tire.get(1)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(1)][1] - min_y) * scale_y), 2.5f, mPaint);
+    mCanvas.drawCircle((float) (base_x + (car[tire.get(2)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(2)][1] - min_y) * scale_y), 2.5f, mPaint);
+    mCanvas.drawCircle((float) (base_x + (car[tire.get(3)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(3)][1] - min_y) * scale_y), 2.5f, mPaint);
+
+    mPaint.setStyle(Paint.Style.STROKE);
+    mPaint.setColor(Color.BLACK);
 
     if (map.length > 9) {
-        Log.d(TAG, "DrawMap X = " + String.format("%f", (float) (base_x + (map[0][0] - min_x) * scale_x)) + " Y = " + String.format("%f", (float) (base_y + (map[0][1] - min_y) * scale_y)));
-        mPath.moveTo((float) (base_x + (map[0][0] - min_x) * scale_x), (float) (base_y + (map[0][1] - min_y) * scale_y));
-        for (int i = 1; i < map.length; i++) {
-            Log.d(TAG, "DrawMap to X = " + (float) (base_x + (map[i][0] - min_x) * scale_x) + " Y = " + (float) (base_y + (map[i][1] - min_y) * scale_y));
-            mPath.lineTo((float) (base_x + (map[i][0] - min_x) * scale_x), (float) (base_y + (map[i][1] - min_y) * scale_y));
-        }
-        mPath.close();
-        mCanvas.drawPath(mPath,mPaint);
-    }
-mPaint.reset();
-        mPath = new Path();
-    mPaint.setStyle(Paint.Style.STROKE);
-    mPaint.setStrokeWidth(1.5f);
-    mPaint.setColor(Color.RED);
-    mPath.moveTo(300,150);
-    mPath.lineTo(1015,150);
+        if (maps != null&& maps.size()>0){
+            for (int i = 0; i < maps.size(); i++) {
+                RoadExamMap.MapsBean mapItem = maps.get(i);
+                if (mapItem.getItem() == ALL_MAP){
+                    List<List<Integer>> redLines= mapItem.getRed_line();
+                    List<List<Integer>> greenLines = mapItem.getGreen_line();
+                    mPaint.reset();
+                    mPaint.setStyle(Paint.Style.STROKE);
+                    mPaint.setStrokeWidth(1.5f);
+                    mPaint.setAntiAlias(true);
+                    mPaint.setColor(Color.RED);
+                    Log.i(TAG,"redLinesSize"+redLines.size());
+                    for (List<Integer> redline: redLines
+                         ) {
+                        for (int j = 0; j < redline.size(); j++) {
+                            Log.i(TAG,"redLiSize"+redline.size());
+                            int pos = redline.get(j);
+                            if (j == 0){
+                                mPath.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y));
+                            }
+                            mPath.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y));
+                            Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1],
+                                    (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y)));
 
-    mCanvas.drawPath(mPath,mPaint);
+                        }
+                    }
+                    mCanvas.drawPath(mPath,mPaint);
+                //鐢昏櫄绾匡紙鍒嗛亾绾匡級
+                    mPaint.reset();
+                    mPaint.setStyle(Paint.Style.STROKE);
+                    mPaint.setStrokeWidth(1.5f);
+                    mPaint.setAntiAlias(true);
+                    mPaint.setColor(Color.WHITE);
+                    mPath = new Path();
+                    mPaint.setPathEffect(new DashPathEffect(new float[] {15, 15}, 0));
+                    for (List<Integer> greenline:
+                            greenLines){
+                        for (int j = 0; j < greenline.size(); j++) {
+                            int pos = greenline.get(j);
+                            if (j == 0){
+                                mPath.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y));
+                            }
+                            mPath.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y));
+                            Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1],
+                                    (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y)));
+                        }
+                    }
+                    mCanvas.drawPath(mPath,mPaint);
+
+                }
+            }
+
+            mPath.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 k = 1; k < body.size(); k++){
+                Log.d(TAG, "for 寰幆 DrawMap to X = " + (float) (base_x + (car[body.get(k)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(k)][1] - min_y) * scale_y));
+                mPath.lineTo((float) (base_x + (car[body.get(k)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(k)][1] - min_y) * scale_y));
+            }
+
+            mPath.close();
+
+            mCanvas.drawPath(mPath, mPaint);
+
+
+
+        }
+
+    }
+
+
+//mPaint.reset();
+//        mPath = new Path();
+//    mPaint.setStyle(Paint.Style.STROKE);
+//    mPaint.setStrokeWidth(1.5f);
+//
+//    for (int i = 0; i < map.length; i++) {
+//        if (i<map.length-3){
+//            mPath.moveTo((float) (base_x + (map[i][0] - min_x) * scale_x), (float) (base_y + (map[i][1] - min_y) * scale_y));
+//            mPath.lineTo((float) (base_x + (map[i+3][0] - min_x) * scale_x), (float) (base_y + (map[i+3][1] - min_y) * scale_y));
+//        }else{
+//            break;
+//        }
+//
+//        i++;
+//    }
+//    mCanvas.drawPath(mPath,mPaint);
 }
 
     /**
@@ -314,4 +513,40 @@
         }
     }
 
+
+
+    class MessageRemoteService{
+        public int msgCode;
+        public String json;
+
+        public MessageRemoteService(int msgCode, Object obj) {
+            this.json = (String) obj;
+            this.msgCode = msgCode;
+        }
+    }
+
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        CEventCenter.onBindEvent(true, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC);
+        CEventCenter.onBindEvent(true, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
+    }
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        generateData.shutdown();
+        drawThread.shutdown();
+        CEventCenter.onBindEvent(false, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC);
+        CEventCenter.onBindEvent(false, speedListener, Constant.BIND_RTK_SPEED_TOPIC);
+    }
+    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;
+            }
+        }
+    };
+
 }
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
index d90b9b6..e01e7e5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -28,6 +28,7 @@
 import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.ListView;
+import android.widget.RelativeLayout;
 import android.widget.TableRow;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -94,6 +95,8 @@
         return new TrainFragment();
     }
 
+    private RelativeLayout relativeLayout;//鍦鸿�冭繕鏄矾鑰�
+
     private int exam_type = 2;//2 鍦哄湴锛�3 閬撹矾锛屾ā鎷熷鑰冿紱4 閬撹矾锛屽疄闄呭鑰冿紱
     private ListView mListView;
     private Button btn_start_exam;
diff --git a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
index 34cfd02..4641db2 100644
--- a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
+++ b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
@@ -322,8 +322,8 @@
         int unsignedTime=  parseUnsignedInt(String.valueOf(longCurrTIme),10);
         System.out.println("unsigned int time = "+unsignedTime);
 
-Point p1 = new Point(1.0,5.0);
-Point p2 = new Point(3.0,5.0);
+Point p1 = new Point(1.0,2.0);
+Point p2 = new Point(1.0,2.0);
         System.out.println(Calc3Point(p1,p2,10.0).toString());
     }
 
@@ -370,7 +370,7 @@
         p3.setX(x3);
         p3.setY(y3);
 
-        p3 = rotatePoint(p3, p2, 270);
+        p3 = rotatePoint(p3, p2, 0);
 
 
         return p3;
diff --git a/app/src/main/res/layout/layout_net_train.xml b/app/src/main/res/layout/layout_net_train.xml
index 3dee05c..d10b307 100644
--- a/app/src/main/res/layout/layout_net_train.xml
+++ b/app/src/main/res/layout/layout_net_train.xml
@@ -52,8 +52,8 @@
             android:background="@drawable/btn_start_bg"
             android:layout_toRightOf="@+id/tv_pos"/>
     </RelativeLayout>
-<include layout="@layout/layout_net_train_item" android:visibility="gone"/>
-<include layout="@layout/layout_road_train" android:visibility="visible"/>
+<include layout="@layout/layout_net_train_item" android:visibility="visible" android:id="@+id/changkao"/>
+<include layout="@layout/layout_road_train" android:visibility="gone" android:id="@+id/lukao"/>
 </LinearLayout>
 
     <include   android:layout_gravity="center_vertical" android:layout_marginLeft="10dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" layout="@layout/layout_train_exit"/>

--
Gitblit v1.8.0