change the render cars color style
This commit is contained in:
@@ -111,36 +111,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
removeUselessLastRecord();
|
||||
|
||||
// 能复用的 marker 数量
|
||||
// int cachedMarkerSize = mMarkersCaches.size();
|
||||
// 需要新增的 marker 数量
|
||||
int newDiffSetSize = newDiffSet.size();
|
||||
Log.d(TAG, "原数据量 : " + resultList.size() + " 新增marker数量 : " + newDiffSetSize);
|
||||
// 能复用的数量
|
||||
// int size = Math.min(cachedMarkerSize, newDiffSetSize);
|
||||
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
// Iterator<Map.Entry<String, IMogoMarker>> entryIterator = mMarkersCaches.entrySet().iterator();
|
||||
// for (int i = 0; i < size; i++) {
|
||||
// ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
|
||||
// String uniqueKey = recognizedListResult.uuid;
|
||||
// Map.Entry<String, IMogoMarker> entry = entryIterator.next();
|
||||
// entryIterator.remove();
|
||||
// ADASRecognizedResult old = mLastPositions.remove(entry.getKey());
|
||||
// IMogoMarker marker = entry.getValue();
|
||||
// if (marker == null) {
|
||||
// continue;
|
||||
// }
|
||||
// // 复用,更新marker 3D资源
|
||||
// if (old == null || old.type != recognizedListResult.type) {
|
||||
// updateCacheMarkerRes(marker, recognizedListResult);
|
||||
// }
|
||||
// Log.d(TAG,"复用marker id : " + uniqueKey);
|
||||
// renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
// }
|
||||
// 复用过后还需新增的 marker
|
||||
// for (int i = size; i < newDiffSetSize; i++) {
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
@@ -152,10 +126,6 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
}
|
||||
}
|
||||
// if (cachedMarkerSize - size > 0) {
|
||||
// sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
// }
|
||||
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
mMarkersCaches.clear();
|
||||
mMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
@@ -279,6 +249,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
final long start = System.currentTimeMillis();
|
||||
Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type);
|
||||
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey);
|
||||
// 道路吸附
|
||||
// double lastLon = -1;
|
||||
// double lastLat = -1;
|
||||
// if (lastPosition != null) {
|
||||
@@ -286,7 +257,6 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
// lastLat = lastPosition.lat;
|
||||
// }
|
||||
// double[] matchLonLat = getMatchLonLat(recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat);
|
||||
//
|
||||
// recognizedListResult.lon = matchLonLat[0];
|
||||
// recognizedListResult.lat = matchLonLat[1];
|
||||
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
@@ -294,8 +264,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
mLastPositions.put(uniqueKey, recognizedListResult);
|
||||
if (useCache) {
|
||||
Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
|
||||
|
||||
long interval = 45;
|
||||
if(lastPosition != null){
|
||||
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
|
||||
}
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
final long intervalRef = interval - cost;
|
||||
@@ -307,10 +279,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
|
||||
}
|
||||
marker.setAnchorColor(carColor);
|
||||
|
||||
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
|
||||
|
||||
// if (shouldShowSpeed(recognizedListResult.type)) {
|
||||
@@ -334,7 +305,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ROAD_UNIT;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
|
||||
import static java.lang.Math.PI;
|
||||
@@ -201,55 +200,26 @@ class BaseDrawer {
|
||||
/**
|
||||
* 根据速度、经纬度计算距离判断车辆颜色
|
||||
*
|
||||
* @param speed 车速 TODO 这里很可能是adas的策略
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return 实际车辆颜色
|
||||
*/
|
||||
protected String getModelRenderColor(int type, int fromType, double speed, double lon, double lat, double angle) {
|
||||
|
||||
// AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
// if (recognizedType == AdasRecognizedType.classIdUnKnow) {
|
||||
// return Car3DModelColor.Normal.color;
|
||||
// }
|
||||
// 距离策略 todo 此处两种策略是临时方案
|
||||
// double[] coordinates = getCurCoordinates();
|
||||
// double distance = CoordinateUtils.calculateLineDistance(lon, lat, coordinates[0], coordinates[1]) * 100;
|
||||
// if (distance < 15) {
|
||||
// return Car3DModelColor.Dangerous.color; // todo 方案1
|
||||
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Dangerous); // todo 方案2
|
||||
// } else if (distance < 50 && distance >= 15) {
|
||||
// return Car3DModelColor.Warming.color; // todo 方案1
|
||||
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Close); // todo 方案2
|
||||
// }
|
||||
|
||||
// 他车车速和自车车速对比速度策略
|
||||
// 自车速度 >= 50% 危险
|
||||
// 10% < 自车速度 < 50% 警告
|
||||
// double curSpeed = getCurSpeed();
|
||||
// if (curSpeed > 0 && speed > curSpeed) {
|
||||
// double rate = ((speed - curSpeed) / curSpeed) * 100;
|
||||
// if (rate >= 50) {
|
||||
// return Car3DModelColor.Dangerous.color; // todo 方案1
|
||||
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Dangerous); // todo 方案2
|
||||
// } else if (rate > 10 && rate < 50) {
|
||||
// return Car3DModelColor.Warming.color; // todo 方案1
|
||||
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Close); // todo 方案2
|
||||
// }
|
||||
// }
|
||||
|
||||
// 默认颜色 // todo 方案1
|
||||
// switch (fromType) {
|
||||
// case FROM_ADAS:
|
||||
// return Car3DModelColor.Normal_Visual.color;
|
||||
// case FROM_ROAD_UNIT:
|
||||
// return Car3DModelColor.Normal_Cloud.color;
|
||||
// default:
|
||||
// return Car3DModelColor.Normal.color;
|
||||
// }
|
||||
protected String getModelRenderColor(int type, int fromType, int drawLevel) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdUnKnow) {
|
||||
return Car3DModelColor.Normal.color;
|
||||
}
|
||||
if (fromType == FROM_ADAS) {
|
||||
switch (drawLevel) {
|
||||
case 1:
|
||||
return Car3DModelColor.Normal.color;
|
||||
case 2:
|
||||
return Car3DModelColor.Warming.color;
|
||||
case 3:
|
||||
return Car3DModelColor.Dangerous.color;
|
||||
default:
|
||||
return Car3DModelColor.Error.color;
|
||||
}
|
||||
}
|
||||
return Car3DModelColor.Normal.color;
|
||||
// todo 方案2
|
||||
// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,18 +271,10 @@ class BaseDrawer {
|
||||
public enum Car3DModelColor {
|
||||
|
||||
Normal("#D8D8D8FF"),
|
||||
Normal_Visual("#D8CFF8BD"),
|
||||
Normal_Cloud("#D8F83F94"),
|
||||
|
||||
Warming("#FFD53EFF"),
|
||||
Warming_Visual("#FFC192F1"),
|
||||
Warming_Cloud("#FFEF09AD"),
|
||||
|
||||
Dangerous("#FF3C45FF"),
|
||||
Dangerous_Visual("#FF91B7F1"),
|
||||
Dangerous_Cloud("#FF260FEC");
|
||||
Error("#00000000");
|
||||
|
||||
private int fromType;
|
||||
private final String color;
|
||||
|
||||
Car3DModelColor(String color) {
|
||||
@@ -321,47 +283,6 @@ class BaseDrawer {
|
||||
|
||||
}
|
||||
|
||||
public static final int Waring_Normal = 0;
|
||||
public static final int Waring_Close = 1;
|
||||
public static final int Waring_Dangerous = 2;
|
||||
|
||||
/**
|
||||
* 模型颜色
|
||||
*/
|
||||
public enum Car3DTestModelColor {
|
||||
|
||||
Normal_Type(FROM_MY_LOCATION, Waring_Normal, "#D8D8D8FF"),
|
||||
Normal_Type_Visual(FROM_ADAS, Waring_Normal, "#D8CFF8BD"),
|
||||
Normal_Type_Cloud(FROM_ROAD_UNIT, Waring_Normal, "#D8F83F94"),
|
||||
|
||||
Warming_Type(FROM_MY_LOCATION, Waring_Close, "#FFD53EFF"),
|
||||
Warming_Type_Visual(FROM_ADAS, Waring_Close, "#FFC192F1"),
|
||||
Warming_Type_Cloud(FROM_ROAD_UNIT, Waring_Close, "#FFEF09AD"),
|
||||
|
||||
Dangerous_Type(FROM_MY_LOCATION, Waring_Dangerous, "#FF3C45FF"),
|
||||
Dangerous_Type_Visual(FROM_ADAS, Waring_Dangerous, "#FF91B7F1"),
|
||||
Dangerous_Type_Cloud(FROM_ROAD_UNIT, Waring_Dangerous, "#FF260FEC");
|
||||
|
||||
private final int fromType;
|
||||
private final int waringType;
|
||||
private final String color;
|
||||
|
||||
Car3DTestModelColor(int fromType, int waringType, String color) {
|
||||
this.fromType = fromType;
|
||||
this.waringType = waringType;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static String getTestModelColor(int fromType, int waringType) {
|
||||
for (Car3DTestModelColor value : Car3DTestModelColor.values()) {
|
||||
if (value.fromType == fromType && value.waringType == waringType) {
|
||||
return value.color;
|
||||
}
|
||||
}
|
||||
return Normal_Type.color;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示车辆速度
|
||||
*
|
||||
|
||||
@@ -179,36 +179,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
removeUselessLastRecord();
|
||||
|
||||
// 能复用的 marker 数量
|
||||
// int cachedMarkerSize = mMarkersCaches.size();
|
||||
// 需要新增的 marker 数量
|
||||
int newDiffSetSize = newDiffSet.size();
|
||||
// 能复用的数量
|
||||
// int size = Math.min(cachedMarkerSize, newDiffSetSize);
|
||||
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
// Iterator<Map.Entry<String, IMogoMarker>> entryIterator = mMarkersCaches.entrySet().iterator();
|
||||
// for (int i = 0; i < size; i++) {
|
||||
// SocketDownData.CloudRoadDataProto cloudRoadData = newDiffSet.get(i);
|
||||
// String uniqueKey = cloudRoadData.getUuid();
|
||||
// Map.Entry<String, IMogoMarker> entry = entryIterator.next();
|
||||
// entryIterator.remove();
|
||||
// SocketDownData.CloudRoadDataProto old = mLastPositions.remove(entry.getKey());
|
||||
// IMogoMarker marker = entry.getValue();
|
||||
// if (marker == null) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // 更新资源内容
|
||||
// if (old == null || old.getType() != cloudRoadData.getType()) {
|
||||
// updateCacheMarkerRes(marker, cloudRoadData);
|
||||
// }
|
||||
// renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
// }
|
||||
|
||||
// 复用过后还需新增的 marker
|
||||
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
SocketDownData.CloudRoadDataProto cloudRoadData = newDiffSet.get(i);
|
||||
String uniqueKey = cloudRoadData.getUuid();
|
||||
@@ -219,10 +191,6 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
renderSnapshotOneFrame(false, marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
}
|
||||
}
|
||||
// if (cachedMarkerSize - size > 0) {
|
||||
// sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
// }
|
||||
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
mMarkersCaches.clear();
|
||||
mMarkersCaches = newMarkersCaches;
|
||||
@@ -318,8 +286,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
mLastPositions.put(uniqueKey, cloudRoadData);
|
||||
|
||||
if (useCache) {
|
||||
long interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
|
||||
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
|
||||
}
|
||||
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
final long intervalRef = interval - cost;
|
||||
@@ -328,10 +298,9 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
marker.setRotateAngle(((float) cloudRoadData.getHeading()));
|
||||
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
}
|
||||
|
||||
newSnapshotCaches.put(uniqueKey, marker);
|
||||
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), 1));
|
||||
|
||||
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading()));
|
||||
if (shouldShowSpeed(cloudRoadData.getType())) {
|
||||
showSelfSpeed(marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), cloudRoadData.getType(), cloudRoadData.getHeading(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
}
|
||||
@@ -448,7 +417,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
String resIdVal;
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
options.set3DMode(true);
|
||||
options.anchorColor(getModelRenderColor(data.getType(), data.getFromType(), data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading()));
|
||||
options.anchorColor(getModelRenderColor(data.getType(), data.getFromType(), 1));
|
||||
int resId = getModelRes(data.getType());
|
||||
resIdVal = resId + "";
|
||||
options.resName(mMarkerCachesResMd5Values.get(resIdVal));
|
||||
|
||||
Reference in New Issue
Block a user