lizhanwei
2020-04-02 b5c6c200d60aae805614495512ab24eafcce1fb9
app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
@@ -46,11 +46,13 @@
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.ExamMap;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.Point;
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;
/**
@@ -214,13 +216,10 @@
        if (canvas2 == null || bmp == null) {
            return;
        }
//        _mActivity.runOnUiThread(new Runnable() {
//            @Override
//            public void run() {
                double base_x = 300, base_y = 20;
                double max_x = 0, min_x = 0, max_y = 0, min_y = 0;
                Log.d(TAG, "DrawMap map size " + map.length + " car size " + car.length);
                Log.d(TAG, "DrawMap map size " + map.length + " car size " + car.length+"map other length="+map_other.length);
                for (int i = 0; i < map.length; i++) {
                    if (i == 0) {
@@ -264,20 +263,20 @@
                Log.d(TAG, "DrawMap max_x " + max_x + " max_y " + max_y + " min_x " + min_x + " min_y " + min_y);
                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];
                    }
                }
//                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];
//                    }
//                }
                Log.d(TAG, "DrawMap max_x " + max_x + " max_y " + max_y + " min_x " + min_x + " min_y " + min_y);
@@ -291,6 +290,7 @@
                }
                Log.d(TAG, "DrawMap scale_x " + scale_x + " scale_y " + scale_y);
                canvas2.drawColor(Color.WHITE);
@@ -752,6 +752,7 @@
                    map_id = timeCarPos.getMap_id();
                    List<Double> mainAnt = timeCarPos.getMain_ant();
                    Point mainPoint = new Point(mainAnt.get(0), mainAnt.get(1));
                    List<Integer> tire1 = timeCarPos.getLeft_front_tire();
                    List<Integer> tire2 = timeCarPos.getRight_front_tire();
                    List<Integer> tire3 = timeCarPos.getLeft_rear_tire();
@@ -857,12 +858,48 @@
                                        if ((k % 2) == 0) {
                                            map[map_line][0] = xys.get(k);
                                        } else {
                                            double value = 0 - xys.get(k);
                                            double value = xys.get(k);
                                            Log.i(TAG, "onCEvent: map新值=" + value + " 位置:" + k);
                                            map[map_line][1] = value;
                                            map_line++;
                                        }
                                    }
                                    Log.i(TAG,String.format("下面开始旋转,map.length=%d",map.length));
                                    Point point2 = new Point(map[0][0],map[0][1]);
                                    double deg = 0.0;
                                    switch (map.length){
                                        case 8:
                                            Point point1 = new Point(map[map.length-1][0],map[map.length-1][1]);
                                            deg = Utils.YawOf(point2,point1);
                                            deg +=270;
                                            for (int k = 0; k < map.length; k++) {
                                                Point point11 = new Point(map[k][0],map[k][1]);
                                                Point point = Utils.rotatePoint(point11,point2,deg);
                                                map[k][0] = point.getX();
                                                map[k][1] = 0-point.getY();
                                                Log.i(TAG,String.format("旋转后的值map[%d][0]=%f,map[%d][1]=%f,deg=%f",k,map[k][0],k,map[k][1],deg));
                                            }
                                            break;
                                        case 9:
                                            break;
                                        case 6:
                                            break;
                                            default:
                                                break;
                                    }
                                    for (int k = 0; k < car.length; k++) {
                                        Point oldPoint = new Point(car[k][0], car[k][1]);
                                        Point newPoint = Utils.rotatePoint(oldPoint, point2, deg );
                                        car[k][0] = newPoint.getX();
                                        car[k][1] = newPoint.getY();
//                                        car[k][0] = car[k][0] - point2.getX();
//                                        car[k][1] = car[k][1] - point2.getY();
//                                        car[k][1] = -car[k][1];
                                        Log.i(TAG,String.format("旋转后的值car[%d][0]=%f,car[%d][1]=%f,deg=%f",k,car[k][0],k,car[k][1],deg));
                                    }
                                }else{
                                    MyLog.i(TAG,"暂时支持曲线");
                                    map_other = new double[xys.size()/2][2];