yy1717
2020-03-05 f430073ef8e63884eff78d57084f89e93fa0c1f0
app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
@@ -8,6 +8,7 @@
import android.graphics.Path;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
@@ -21,6 +22,7 @@
import androidx.appcompat.widget.Toolbar;
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -42,6 +44,7 @@
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.ExamMap;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.RealTimeCarPos;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
@@ -284,7 +287,7 @@
                paint.setColor(Color.BLACK);
                Path path = new Path();
        Log.i(TAG, "DrawMap: map.length:"+map.length);
                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)));
                    path.moveTo((float) (base_x + (map[0][0] - min_x) * scale_x), (float) (base_y + (map[0][1] - min_y) * scale_y));
@@ -312,8 +315,10 @@
                canvas2.drawPath(path, paint);
                path.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++)
                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));
                    path.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));
                }
                path.close();
@@ -481,12 +486,29 @@
//            3 - 侧方停车
//            4 - 曲线行驶
//            5 - 直角转弯
                    StringBuffer buffer=null;
                    List<ExamMap> examMaps;
                    String newmap = null;
                    String mapPath = ExamPlatformData.getInstance().getMapPath();
                    if (!TextUtils.isEmpty(mapPath)){
                        MyLog.i("调用更新Map路径后的地图"+mapPath);
                        byte[] fileContent = FileUtil.readFile(mapPath);
                        if (fileContent != null){
                            newmap= new String(fileContent);
                            Log.i(TAG, "文件内容:"+newmap);
                        }else{
                            MyLog.i(String.format("文件:%s不存在",mapPath));
                        }
                    }else{
                        buffer = FileUtil.readAssetTxtFile(_mActivity,Constant.MAP);
                    }
                    StringBuffer buffer = FileUtil.readAssetTxtFile(_mActivity,Constant.MAP);
                    Type type = new TypeToken<List<ExamMap>>(){}.getType();
                    if (buffer != null){
                        List<ExamMap> examMaps = gson.fromJson(buffer.toString().trim(), type);
                       examMaps= gson.fromJson(buffer.toString().trim(), type);
                    }else{
                        examMaps = gson.fromJson(newmap.trim(),type);
                    }
@@ -519,7 +541,7 @@
                                break;
                            }
                        }
                    }
                    DrawMap(mainAnt, map, car, body, tire);
                }
            }