| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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)); |
| | |
| | | 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(); |
| | | |
| | |
| | | // 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); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | DrawMap(mainAnt, map, car, body, tire); |
| | | } |
| | | } |