From d2e846db8685fecddd2307a9d8be623de90ee53a Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期五, 20 三月 2020 17:44:20 +0800
Subject: [PATCH] 修改路考地图
---
app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java | 56 +++++++++++----------------
app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java | 36 ++++--------------
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java | 4 +-
3 files changed, 33 insertions(+), 63 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
index 10518fe..99bb189 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -580,10 +580,10 @@
// 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;
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
index 65ac4fa..29b98bb 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragment.java
@@ -350,6 +350,8 @@
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));
@@ -377,6 +379,21 @@
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){
@@ -390,18 +407,16 @@
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)));
}
}
@@ -422,8 +437,8 @@
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);
@@ -431,15 +446,6 @@
}
}
- 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);
@@ -448,22 +454,6 @@
}
-//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);
}
/**
@@ -473,8 +463,8 @@
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);
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
index 79f7915..8b719c1 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/RoadDriveMapFragmentaa.java
@@ -112,17 +112,13 @@
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鐨勭埗瀹瑰櫒锛屼负浜嗙Щ鍔╯urfaceview鑰屼娇鐢紝鍥犱负scrollto涓嶈兘绉诲姩view锛�
private LinkedBlockingQueue queue = new LinkedBlockingQueue(100);
private ExecutorService producer = Executors.newSingleThreadExecutor();
private ExecutorService consumer = Executors.newSingleThreadExecutor();
@@ -227,23 +223,7 @@
}
}
}
- 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);
@@ -308,6 +288,7 @@
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
) {
@@ -323,13 +304,13 @@
}
}
-// 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){
@@ -353,8 +334,7 @@
}
- 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));
@@ -366,7 +346,8 @@
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);
@@ -446,8 +427,7 @@
boolean flag = true;
class CalRunnable implements Runnable{
- private String json;
- private int cmd;
+
@Override
public void run() {
@@ -490,7 +470,7 @@
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);
--
Gitblit v1.8.0