fctom1215
2020-07-26 d505158845f40372b03d42abd0047942c977cd53
绘图优化
1个文件已修改
115 ■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java 115 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
@@ -748,6 +748,9 @@
        }
        scale_x = Math.round(Math.abs(50 / Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)) ));
        scale_x = 3;
        scale_y = scale_x;
        base_x = bmp.getWidth() / 2;
@@ -805,17 +808,42 @@
                        List<Integer> line = edgeBean.getLine();
                        Log.d(TAG, "路边沿 " + y + " 分段 " + line.size());
                        path.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y));
                        Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1]));
                        int draw_status = 0;
                        for (int z = 1; z < line.size(); z++) {
                            path.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y));
                            Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1]));
                        for (int z = 0; z < line.size(); z++) {
                            float scr_x = (float) (base_x + (map[line.get(z)][0] - min_x) * scale_x);
                            float scr_y = (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y);
                            if (scr_x >= 0 && scr_x <= bmp.getWidth() && scr_y >= 0 && scr_y <= bmp.getHeight()) {
                                if (draw_status == 0) {
                                    path.moveTo(scr_x, scr_y);
                                    draw_status = 1;
                                } else if (draw_status == 1) {
                                    path.lineTo(scr_x, scr_y);
                                }
                            } else if (draw_status == 1) {
                                canvas2.drawPath(path, paint);
                                draw_status = 0;
                            }
                        }
                        Log.d(TAG, "路边沿......");
                        canvas2.drawPath(path, paint);
                        Log.d(TAG, "路边沿完毕");
                        if (draw_status == 1) {
                            canvas2.drawPath(path, paint);
                            draw_status = 0;
                        }
//                        path.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y));
//
//                        Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1]));
//
//                        for (int z = 1; z < line.size(); z++) {
//                            path.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y));
//                            Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1]));
//                        }
//                        Log.d(TAG, "路边沿......");
//                        canvas2.drawPath(path, paint);
                        Log.d(TAG, "左路边沿完毕");
                    }
                }
@@ -838,17 +866,42 @@
                        Path edgePath = new Path();
                        Log.d(TAG, "路边沿 " + y + " 分段 " + line.size());
                        edgePath.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y));
                        Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1]));
                        int draw_status = 0;
                        for (int z = 1; z < line.size(); z++) {
                            edgePath.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y));
                            Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1]));
                        for (int z = 0; z < line.size(); z++) {
                            float scr_x = (float) (base_x + (map[line.get(z)][0] - min_x) * scale_x);
                            float scr_y = (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y);
                            if (scr_x >= 0 && scr_x <= bmp.getWidth() && scr_y >= 0 && scr_y <= bmp.getHeight()) {
                                if (draw_status == 0) {
                                    edgePath.moveTo(scr_x, scr_y);
                                    draw_status = 1;
                                } else if (draw_status == 1) {
                                    edgePath.lineTo(scr_x, scr_y);
                                }
                            } else if (draw_status == 1) {
                                canvas2.drawPath(edgePath, paint);
                                draw_status = 0;
                            }
                        }
                        Log.d(TAG, "路边沿......");
                        canvas2.drawPath(edgePath, paint);
                        Log.d(TAG, "路边沿完毕");
                        if (draw_status == 1) {
                            canvas2.drawPath(edgePath, paint);
                            draw_status = 0;
                        }
//                        edgePath.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y));
//
//                        Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1]));
//
//                        for (int z = 1; z < line.size(); z++) {
//                            edgePath.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y));
//                            Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1]));
//                        }
//                        Log.d(TAG, "路边沿......");
//                        canvas2.drawPath(edgePath, paint);
                        Log.d(TAG, "右路边沿完毕");
                    }
                }
@@ -881,12 +934,34 @@
                                List<Integer> points = seg.getLine();
                                int draw_status = 0;
                                sepPath.moveTo((float) (base_x + (map[points.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(0)][1] - min_y) * scale_y));
                                for (int za = 1; za < points.size(); za++) {
                                    sepPath.lineTo((float) (base_x + (map[points.get(za)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(za)][1] - min_y) * scale_y));
                                for (int za = 0; za < points.size(); za++) {
                                    float scr_x = (float) (base_x + (map[points.get(za)][0] - min_x) * scale_x);
                                    float scr_y = (float) (base_y + (map[points.get(za)][1] - min_y) * scale_y);
                                    if (scr_x >= 0 && scr_x <= bmp.getWidth() && scr_y >= 0 && scr_y <= bmp.getHeight()) {
                                        if (draw_status == 0) {
                                            sepPath.moveTo(scr_x, scr_y);
                                            draw_status = 1;
                                        } else if (draw_status == 1) {
                                            sepPath.lineTo(scr_x, scr_y);
                                        }
                                    } else if (draw_status == 1) {
                                        canvas2.drawPath(sepPath, paint);
                                        draw_status = 0;
                                    }
                                }
                                canvas2.drawPath(sepPath, paint);
                                if (draw_status == 1) {
                                    canvas2.drawPath(sepPath, paint);
                                    draw_status = 0;
                                }
//                                sepPath.moveTo((float) (base_x + (map[points.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(0)][1] - min_y) * scale_y));
//                                for (int za = 1; za < points.size(); za++) {
//                                    sepPath.lineTo((float) (base_x + (map[points.get(za)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(za)][1] - min_y) * scale_y));
//                                }
//                                canvas2.drawPath(sepPath, paint);
                            }
                        }