This commit is contained in:
zhongchao
2021-04-15 17:47:37 +08:00
14 changed files with 131 additions and 85 deletions

View File

@@ -158,7 +158,7 @@ public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPrese
} else if ( isArriveAtStartStation ) {
showSlidePanle( "准备出发" );
} else if ( isArriveAtStation ) {
showSlidePanle( "乘客已上车,准备出发" );
showSlidePanle( "滑动出车" );
}
mCurrentStationName.setText( currentStationName );

View File

@@ -5,6 +5,7 @@ import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
@@ -17,7 +18,6 @@ import com.amap.api.navi.AMapNaviView;
import com.amap.api.navi.AMapNaviViewOptions;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
import com.mogo.utils.FileUtils;
import java.io.IOException;
@@ -32,8 +32,6 @@ public class SmallMapDirectionView extends RelativeLayout {
private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data";
private AMapNaviView mAMapNaviView;
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
private int zoomLevel = 15;
public SmallMapDirectionView(Context context) {
@@ -54,9 +52,9 @@ public class SmallMapDirectionView extends RelativeLayout {
}
private void initView(Context context) {
mRotateAnimation = new DirectionRotateAnimation(context, null);
AbsMogoApplication.getLayoutInflaterNoSkin().inflate(R.layout.module_small_map_view, this);
mAMapNaviView = findViewById(R.id.aMapNaviView);
mAMapNaviView.onCreate(null);
@@ -164,7 +162,6 @@ public class SmallMapDirectionView extends RelativeLayout {
try {
// 判断是否有样式文件存在
//File styleExit = new File(styleFilePath);
FileUtils.copy(
context.getAssets().open("small_map_style.data"),
styleFilePath,

View File

@@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_40"
tools:parentTag="RelativeLayout">
@@ -12,6 +11,7 @@
android:layout_width="@dimen/module_small_map_view_border_width"
android:layout_height="@dimen/module_small_map_view_border_height"
android:layout_centerInParent="true"
android:layout_margin="@dimen/module_small_map_padding"
android:background="@drawable/module_small_map_view_border" />
<com.mogo.module.common.view.RoundLayout

View File

@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_small_map_padding">30px</dimen>
<dimen name="module_small_map_border_view_width">400px</dimen>
<dimen name="module_small_map_border_view_height">400px</dimen>
<dimen name="module_small_map_view_border_width">288px</dimen>
<dimen name="module_small_map_view_border_height">288px</dimen>
<dimen name="module_small_map_view_width">270px</dimen>
<dimen name="module_small_map_view_height">270px</dimen>
<dimen name="module_small_map_view_width">260px</dimen>
<dimen name="module_small_map_view_height">260px</dimen>
<dimen name="module_small_map_view_x">1620px</dimen>
<dimen name="module_small_map_view_y">780px</dimen>

View File

@@ -1,8 +1,18 @@
package com.mogo.module.v2x.listener;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
@@ -20,6 +30,24 @@ public class V2XMessageListener_401019 implements IMogoOnMessageListener<V2XOpti
@Override
public void onMsgReceived(V2XOptimalRouteDataRes message) {
Logger.i(MODULE_NAME, "V2XMessageListener_401019" + message);
// 将接收到的数据转换成最优车道推荐的场景数据
if (message != null
&& message.getLocus_list() != null
&& !message.getLocus_list().isEmpty()) {
V2XMessageEntity<V2XOptimalRouteDataRes> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(message);
// 控制展示状态
v2xMessageEntity.setShowState(true);
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
}
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.module.v2x.observer;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.v2x.overlay.V2XOptimalRouteOverlay;
@@ -17,7 +18,7 @@ public class V2XOptimalRouteObserver extends CarLocationObserver {
//最优路线覆盖物绘制
private V2XOptimalRouteOverlay mV2XOptimalRouteOverlay;
// 要绘制的数据
private List<double[]> polylinePoint;
private List<MogoLatLng> polylinePoint;
public static V2XOptimalRouteObserver getInstance() {
if (v2XOptimalRouteObserver == null) {
@@ -39,7 +40,7 @@ public class V2XOptimalRouteObserver extends CarLocationObserver {
*
* @param polylinePoint 推荐的路线
*/
public void setPolylinePoint(List<double[]> polylinePoint) {
public void setPolylinePoint(List<MogoLatLng> polylinePoint) {
this.polylinePoint = polylinePoint;
}

View File

@@ -39,7 +39,7 @@ public class V2XOptimalRouteOverlay {
*
* @param polylinePoint 要绘制的经纬度度集合
*/
public IMogoPolyline draw(MogoLocation carLocal, List<double[]> polylinePoint) {
public IMogoPolyline draw(MogoLocation carLocal, List<MogoLatLng> polylinePoint) {
if (mMoGoPolyline != null) {
mMoGoPolyline.remove();
mPolylinePointList.clear();
@@ -48,11 +48,10 @@ public class V2XOptimalRouteOverlay {
// 将当前车辆位置放进去
mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
// 过滤后台推送的推荐路线集合
for (double[] polyline : polylinePoint) {
MogoLatLng pointMoGoLatLng = new MogoLatLng(polyline[1], polyline[0]);
for (MogoLatLng polyline : polylinePoint) {
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中的点是否在当前车辆行驶方向前面如果不在则抛弃
if (LocationUtils.isPointOnCarFront(carLocal, pointMoGoLatLng)) {
mPolylinePointList.add(pointMoGoLatLng);
if (LocationUtils.isPointOnCarFront(carLocal, polyline)) {
mPolylinePointList.add(polyline);
}
}
// 替换路径集合

View File

@@ -104,11 +104,6 @@ public class V2XScenarioManager implements IV2XScenarioManager {
mV2XScenario = new V2XRecommendRouteScenario();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
// if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
//
// } else {
// mV2XScenario = null;
// }
mV2XScenario = new V2XOptimalRouteVREventScenario();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP:

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.scenario.scene.route;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.observer.V2XOptimalRouteObserver;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.utils.MarkerUtils;
@@ -15,11 +16,11 @@ import com.mogo.utils.logger.Logger;
* desc : 推送VR场景
* version: 1.0
*/
public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XOptimalRouteDataRes> {
private final String TAG = "V2XPushVREventMarker";
@Override
public void drawPOI(V2XPushMessageEntity entity) {
public void drawPOI(V2XOptimalRouteDataRes entity) {
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "drawPOI 绘制VR Marker");
try {
@@ -27,21 +28,13 @@ public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEn
V2XServiceManager
.getMoGoV2XMarkerManager().clearALLPOI();
// 绘制引导线
drawableRecommendPolyline(entity);
V2XOptimalRouteObserver.getInstance()
.setPolylinePoint(entity.getLocus_list());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 绘制推荐引导线
*
* @param entity
*/
void drawableRecommendPolyline(V2XPushMessageEntity entity) {
V2XOptimalRouteObserver.getInstance().setPolylinePoint(entity.getRecommendPolyline());
}
@Override
public void clearPOI() {
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随

View File

@@ -6,10 +6,10 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
@@ -25,7 +25,7 @@ import com.mogo.utils.network.utils.GsonUtil;
* wiki : http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52829799
*/
public class V2XOptimalRouteVREventScenario
extends AbsV2XScenario<V2XPushMessageEntity>
extends AbsV2XScenario<V2XOptimalRouteDataRes>
implements IMogoTopViewStatusListener {
private String TAG = "V2XPushVREventWindow";
@@ -35,7 +35,7 @@ public class V2XOptimalRouteVREventScenario
}
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
public void init(@Nullable V2XMessageEntity<V2XOptimalRouteDataRes> v2XMessageEntity) {
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR" + GsonUtil.jsonFromObject(v2XMessageEntity));
if (!isSameScenario(v2XMessageEntity)
@@ -53,7 +53,7 @@ public class V2XOptimalRouteVREventScenario
@Override
public void show() {
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
speakTTSVoice(getV2XMessageEntity().getContent().getTts(), null);
speakTTSVoice("已为您选择最优路线", null);
drawPOI();
showWindow();
}

View File

@@ -6,9 +6,9 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.scenario.scene.V2XBasWindow;
import com.mogo.module.v2x.scenario.view.IV2XWindow;
@@ -24,7 +24,9 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* TODO 只有VR演示场景使用
* version: 1.0
*/
public class V2XOptimalRouteVREventWindow extends V2XBasWindow implements IV2XWindow<V2XPushMessageEntity> {
public class V2XOptimalRouteVREventWindow
extends V2XBasWindow
implements IV2XWindow<V2XOptimalRouteDataRes> {
private String TAG = "V2XPushVREventWindow";
// 处理道路事件30秒倒计时
@@ -54,8 +56,7 @@ public class V2XOptimalRouteVREventWindow extends V2XBasWindow implements IV2XWi
* 展示道路事件详情Windows
*/
@Override
public void show(V2XPushMessageEntity entity) {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息:展示 Window=\n" + entity);
public void show(V2XOptimalRouteDataRes entity) {
countDownV2XEvent();
}

View File

@@ -24,6 +24,7 @@ import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.alarm.V2XAlarmServer;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
@@ -378,8 +379,8 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
*拥堵路线推荐
* */
btnTriggerCongestedRouteRecommendation.setOnClickListener(v -> {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushVR();
V2XMessageEntity<V2XOptimalRouteDataRes> v2XMessageEntity =
TestOnLineCarUtils.getV2XOptimalRoute();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);

View File

@@ -10,6 +10,7 @@ import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.utils.network.utils.GsonUtil;
@@ -455,4 +456,37 @@ public class TestOnLineCarUtils {
}
return null;
}
/**
* 模拟最优路线推送
*/
public static V2XMessageEntity<V2XOptimalRouteDataRes> getV2XOptimalRoute() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_push_vr_event_data_yongdu_gongsi_1);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = -1;
byte[] buffer = new byte[1024];
while ((len = inputStream.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
inputStream.close();
// 加载数据源
V2XOptimalRouteDataRes v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XOptimalRouteDataRes.class);
V2XMessageEntity<V2XOptimalRouteDataRes> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -1,45 +1,40 @@
{
"sceneId": "200008",
"alarmContent": "拥堵路线推荐",
"expireTime": 10000,
"sceneCategory": 0,
"sceneDescription": "拥堵路线推荐",
"sceneName": "拥堵路线推荐",
"sceneLevel": 0,
"videoUrl": "",
"videoChannel": "",
"videoSn": "",
"tts": "发现前方拥堵最优路线快6分钟",
"zoom": false,
"zoomScale": 15,
"userHead": "",
"msgImgUrl": "",
"lat":39.969088,
"lon":116.41808,
"recommendPolyline": [
[
116.417388,39.983351
],
[
116.417351,39.9841
],
[
116.417286,39.985423
],
[
116.417233,39.98673
],
[
116.417179,39.988156
],
[
116.417158,39.988493
],
[
116.417142,39.989245
],
[
116.417174,39.990199
]
"locus_list": [
{
"lon": 116.417388,
"lat": 39.983351
},
{
"lon": 116.417388,
"lat": 39.983351
},
{
"lon": 116.417351,
"lat": 39.9841
},
{
"lon": 116.417286,
"lat": 39.985423
},
{
"lon": 116.417233,
"lat": 39.98673
},
{
"lon": 116.417179,
"lat": 39.988156
},
{
"lon": 116.417158,
"lat": 39.988493
},
{
"lon": 116.417142,
"lat": 39.989245
},
{
"lon": 116.417174,
"lat": 39.990199
}
]
}