| | |
| | | // mapFragment = (MapFragment) MapFragment.newInstance(); |
| | | // } |
| | | // start(mapFragment); |
| | | RoadDriveMapFragment mapFragment = findFragment(RoadDriveMapFragment.class); |
| | | RoadDriveMapFragmentaa mapFragment = findFragment(RoadDriveMapFragmentaa.class); |
| | | MyLog.i(TAG,"查看地图"); |
| | | if (mapFragment == null) { |
| | | mapFragment = (RoadDriveMapFragment) RoadDriveMapFragment.newInstance(); |
| | | mapFragment = (RoadDriveMapFragmentaa) RoadDriveMapFragmentaa.newInstance(); |
| | | } |
| | | start(mapFragment); |
| | | break; |
| | |
| | | min_y = car[i][1]; |
| | | } |
| | | } |
| | | //绘制背景 清屏 |
| | | mCanvas.drawColor(Color.WHITE); |
| | | |
| | | 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)); |
| | |
| | | |
| | | mPaint.setStyle(Paint.Style.STROKE); |
| | | mPaint.setColor(Color.BLACK); |
| | | mPaint.reset(); |
| | | mPaint.setStyle(Paint.Style.STROKE); |
| | | mPaint.setStrokeWidth(1.5f); |
| | | mPaint.setAntiAlias(true); |
| | | mPaint.setColor(Color.BLACK); |
| | | 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.i(TAG,String.format("car[%d][0]=%f,to X =%f,car[%d][1]=%f,to Y=%f",k,car[body.get(k)][0], |
| | | (float) (base_x + (car[body.get(k)][0] - min_x) * scale_x),k,car[body.get(k)][1],(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); |
| | | |
| | | if (map.length > 9) { |
| | | if (maps != null&& maps.size()>0){ |
| | |
| | | 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))); |
| | | // 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))); |
| | | |
| | | } |
| | | } |
| | |
| | | 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))); |
| | | // 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | try { |
| | | //获得canvas对象 |
| | | mCanvas = mSurfaceHolder.lockCanvas(); |
| | | //绘制背景 |
| | | mCanvas.drawColor(Color.WHITE); |
| | | // //绘制背景 |
| | | // mCanvas.drawColor(Color.WHITE); |
| | | Log.i(TAG,"width="+mCanvas.getWidth()+"height:"+mCanvas.getHeight()); |
| | | //绘制路径 |
| | | mCanvas.drawPath(mPath, mPaint); |
| | |
| | | private int map_id; |
| | | private double gpsSpeed = 0; |
| | | |
| | | double allMap[][][]; |
| | | double map[][] = {{-2.4065, 30.7090}, {-3.0759, 30.3599}, { -2.6023, 29.2578}, {-3.3316,28.9383},{-3.8247,30.0293}, |
| | | {-3.4503,30.1946}, {-2.9669,29.0981}, { -3.6962, 28.7786}, {-4.1991, 29.8640}}; |
| | | double map_other[][] = {{-2.4065, 30.7090}, {-3.0759, 30.3599}, { -2.6023, 29.2578}, {-3.3316,28.9383},{-3.8247,30.0293}, |
| | | {-3.4503,30.1946}, {-2.9669,29.0981}}; |
| | | |
| | | // double map[][] ; |
| | | 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}}; |
| | | Gson gson; |
| | | private LinearLayout linearLayout;//surfaceview的父容器,为了移动surfaceview而使用,因为scrollto不能移动view, |
| | | private LinkedBlockingQueue queue = new LinkedBlockingQueue(100); |
| | | private ExecutorService producer = Executors.newSingleThreadExecutor(); |
| | | private ExecutorService consumer = Executors.newSingleThreadExecutor(); |
| | |
| | | } |
| | | } |
| | | } |
| | | if (map_other.length>9){ |
| | | for (int i = 0; i < map_other.length; i++) { |
| | | |
| | | if (max_x < map_other[i][0]) { |
| | | max_x = map_other[i][0]; |
| | | } |
| | | if (min_x > map_other[i][0]) { |
| | | min_x = map_other[i][0]; |
| | | } |
| | | if (max_y < map_other[i][1]) { |
| | | max_y = map_other[i][1]; |
| | | } |
| | | if (min_y > map_other[i][1]) { |
| | | min_y = map_other[i][1]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Log.d(TAG, "DrawMap max_x " + max_x + " max_y " + max_y + " min_x " + min_x + " min_y " + min_y); |
| | |
| | | paint.setStrokeWidth(1.5f); |
| | | paint.setAntiAlias(true); |
| | | paint.setColor(Color.RED); |
| | | paint.setPathEffect(null); |
| | | Log.i(TAG,"redLinesSize"+redLines.size()); |
| | | for (List<Integer> redline: redLines |
| | | ) { |
| | |
| | | |
| | | } |
| | | } |
| | | // canvas2.drawPath(path,paint); |
| | | canvas2.drawPath(path,paint); |
| | | //画虚线(分道线) |
| | | paint.reset(); |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setStrokeWidth(1.5f); |
| | | paint.setAntiAlias(true); |
| | | paint.setColor(Color.WHITE); |
| | | // paint.setColor(Color.WHITE); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {15, 15}, 0)); |
| | | for (List<Integer> greenline: |
| | | greenLines){ |
| | |
| | | |
| | | |
| | | } |
| | | canvas2.drawPath(path, paint); |
| | | |
| | | // 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++){ |
| | | 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)); |
| | |
| | | canvas2.drawPath(path, paint); |
| | | |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | |
| | | paint.setPathEffect(null); |
| | | paint.setColor(Color.BLACK); |
| | | if (osdHeading != null) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo(10, 170); |
| | |
| | | boolean flag = true; |
| | | class CalRunnable implements Runnable{ |
| | | |
| | | private String json; |
| | | private int cmd; |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | |
| | | |
| | | |
| | | car = new double[points.size() / 2][2]; |
| | | |
| | | line =0 ;map_line=0; |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if ((i % 2) == 0) { |
| | | car[line][0] = points.get(i); |