From e61eb1c6fe377272b6614dc2b1b7046f007fb69c Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期二, 14 一月 2020 18:33:16 +0800
Subject: [PATCH] 动态加载地图根据map_id
---
app/src/main/java/safeluck/drive/evaluation/bean/ExamMap.java | 61 ++++++++++++++++++++++++++++++
app/src/main/java/safeluck/drive/evaluation/bean/RealTimeCarPos.java | 9 ++++
app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java | 40 +++++++++++++++++++
3 files changed, 109 insertions(+), 1 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/ExamMap.java b/app/src/main/java/safeluck/drive/evaluation/bean/ExamMap.java
new file mode 100644
index 0000000..920c132
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/ExamMap.java
@@ -0,0 +1,61 @@
+package safeluck.drive.evaluation.bean;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+/**
+ * MyApplication2
+ * Created by lzw on 2020/1/14. 18:20:54
+ * 閭锛�632393724@qq.com
+ * All Rights Saved! Chongqing AnYun Tech co. LTD
+ */
+public class ExamMap {
+
+ /**
+ * id : 863
+ * item : 1
+ * point : [{"x-y":[-11.9669,28.013,-11.5114,27.137,-10.8069,27.5039,-10.2969,26.4212,-9.2102,26.8894,-9.6513,28.0027,-8.9758,28.3797,-9.5057,29.3232]},{"x-y":[-11.9669,28.013,-11.5114,27.137,-10.8069,27.5039,-10.2969,26.4212,-9.2102,26.8894,-9.6513,28.0027,-8.9758,28.3797,-9.5057,29.3232]}]
+ */
+
+ private int id;
+ private int item;
+ private List<PointBean> point;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getItem() {
+ return item;
+ }
+
+ public void setItem(int item) {
+ this.item = item;
+ }
+
+ public List<PointBean> getPoint() {
+ return point;
+ }
+
+ public void setPoint(List<PointBean> point) {
+ this.point = point;
+ }
+
+ public static class PointBean {
+ @SerializedName("x-y")
+ private List<Double> xy;
+
+ public List<Double> getXy() {
+ return xy;
+ }
+
+ public void setXy(List<Double> xy) {
+ this.xy = xy;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/RealTimeCarPos.java b/app/src/main/java/safeluck/drive/evaluation/bean/RealTimeCarPos.java
index cf82f07..0f1c7ca 100644
--- a/app/src/main/java/safeluck/drive/evaluation/bean/RealTimeCarPos.java
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/RealTimeCarPos.java
@@ -31,6 +31,7 @@
private List<Integer> right_front_tire;
private List<Integer> left_rear_tire;
private List<Integer> right_rear_tire;
+ private List<Integer> body;
private List<Double> point;
public String getUtc() {
@@ -129,6 +130,14 @@
this.right_rear_tire = right_rear_tire;
}
+ public List<Integer> getBody() {
+ return body;
+ }
+
+ public void setBody(List<Integer> body) {
+ this.body = body;
+ }
+
public List<Double> getPoint() {
return point;
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
index a4c77f5..c403a25 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
@@ -24,17 +24,21 @@
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
import java.util.List;
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.R;
+import safeluck.drive.evaluation.bean.ExamMap;
import safeluck.drive.evaluation.bean.RealTimeCarPos;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
+import safeluck.drive.evaluation.util.FileUtil;
/**
@@ -66,6 +70,7 @@
private String osd = null;
private String osd2 = null;
private String osd3 = null;
+ private int map_id;
double map[][] = {{1, 1}, {10, 1}, {10, 10}, {1, 10}};
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}};
@@ -312,6 +317,7 @@
}
int line = 0;
+ int map_line = 0;
private ICEventListener icEventListener = new ICEventListener() {
@Override
public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
@@ -319,6 +325,7 @@
RealTimeCarPos timeCarPos = gson.fromJson((String) obj, RealTimeCarPos.class);
List<Double> points = timeCarPos.getPoint();
line = 0;
+ map_line = 0;
for (int i = 0; i < points.size(); i++) {
if ((i % 2) == 0) {
@@ -331,7 +338,38 @@
}
}
- CThreadPoolExecutor.runInBackground(new NeedForSpeed(car,map));
+ map_id = timeCarPos.getMap_id();
+// 1 - 鍊掑簱
+// 2 - 鍧¤捣
+// 3 - 渚ф柟鍋滆溅
+// 4 - 鏇茬嚎琛岄┒
+// 5 - 鐩磋杞集
+
+
+ StringBuffer buffer = FileUtil.readTxtFileFromSD(_mActivity,Constant.MAP);
+ Type type = new TypeToken<List<ExamMap>>(){}.getType();
+ if (buffer != null){
+ List<ExamMap> examMaps = gson.fromJson(buffer.toString().trim(), type);
+ for (int i = 0; i < examMaps.size(); i++) {
+ ExamMap examMap = examMaps.get(i);
+ if (map_id == examMap.getId()){
+ List<ExamMap.PointBean> pointBeanList = examMap.getPoint();
+ for(int j=0; j<pointBeanList.size();j++){
+ if ((j % 2) == 0) {
+ map[map_line][0] = points.get(i);
+ } else {
+ double value = 0 - points.get(i);
+ Log.i(TAG, "onCEvent: map鏂板��=" + value + " 浣嶇疆锛�" + i);
+ map[map_line][1] = value;
+ map_line++;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ CThreadPoolExecutor.runInBackground(new NeedForSpeed(car, map));
}
};
--
Gitblit v1.8.0