开始研发最优路线推荐功能

This commit is contained in:
董宏宇
2021-03-26 13:51:40 +08:00
parent 3335bd8402
commit 0f147edec9
7 changed files with 20 additions and 87 deletions

1
.idea/gradle.xml generated
View File

@@ -91,6 +91,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

2
.idea/misc.xml generated
View File

@@ -8,7 +8,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="12" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -1,17 +1,6 @@
package com.mogo.module.common.drawer;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.drawer.marker.MapVrMarkerView;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import java.util.ArrayList;
import java.util.List;
/**
* @author donghongyu
@@ -20,11 +9,10 @@ import java.util.List;
*/
public class PushRoadConditionDrawer {
private static final String TAG = "OnlineCarDrawer";
private static final String TAG = "PushRoadConditionDrawer";
private static volatile PushRoadConditionDrawer sInstance;
private static IMogoPolyline mMogoPolyline;
private static IMogoMarker mMogoMarker;
private PushRoadConditionDrawer() {
}
@@ -41,57 +29,11 @@ public class PushRoadConditionDrawer {
}
public synchronized void release() {
clearMarker();
clearPolyline();
mMogoPolyline = null;
mMogoMarker = null;
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
/**
* 绘制路况事件Marker移动轨迹
*/
public void drawRoadConditionMarker(V2XPushMessageEntity entity) {
// 道路事件
MogoMarkerOptions options = new MogoMarkerOptions()
.object(entity)
.latitude(entity.getLat())
.longitude(entity.getLon());
options.anchor(0.5f, 0.5f);
options.icon(MapVrMarkerView.getInstance().getBitmap(entity.getSceneId()));
mMogoMarker =
MogoApisHandler
.getInstance()
.getApis()
.getMapServiceApi()
.getMarkerManager(AbsMogoApplication.getApp())
.addMarker(DataTypes.TYPE_MARKER_PUSH_DATA, options);
List<MogoLatLng> points = new ArrayList<>();
for (double[] doubles : entity.getMoveTrack()) {
points.add(new MogoLatLng(doubles[1], doubles[0]));
}
mMogoMarker.startSmooth(points, 10);
}
public void clearMarker() {
if (mMogoMarker != null) {
mMogoMarker.remove();
}
}
public void clearPolyline() {
if (mMogoPolyline != null) {
mMogoPolyline.remove();

View File

@@ -48,8 +48,6 @@ public class V2XPushMessageEntity implements Serializable {
private List<double[]> polyline;
private List<double[]> moveTrack;
private List<double[]> recommendPolyline;
public int getViewType() {
@@ -283,14 +281,6 @@ public class V2XPushMessageEntity implements Serializable {
this.polyline = polyline;
}
public List<double[]> getMoveTrack() {
return moveTrack;
}
public void setMoveTrack(List<double[]> moveTrack) {
this.moveTrack = moveTrack;
}
public List<double[]> getRecommendPolyline() {
return recommendPolyline;
}

View File

@@ -1,5 +1,7 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.graphics.Color;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
@@ -39,10 +41,6 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
// 绘制事件点Marker
PushRoadConditionDrawer.getInstance().drawRoadConditionMarker(entity);
// 绘制引导线
drawablePloyLine(entity);
drawableRecommendPolyline(entity);
@@ -67,7 +65,7 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
colors.add(0xFFFA8C34);
// 线条粗细,渐变,渐变色值
options.width(15).useGradient(true).color(0xFF1F7EFF);
options.width(300).useGradient(false).color(Color.argb(255, 255, 0, 0));
for (double[] doubles : entity.getPolyline()) {
options.add(doubles[0], doubles[1]);

View File

@@ -7,7 +7,9 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ToggleButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -62,7 +64,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerEventUgc;
private Button mBtnTriggerTrafficSearch;
private Button mBtnTriggerRecommendRouteEvent;
private Button nBtnTriggerVR;
private ToggleButton nBtnTriggerVR;
private Button btnTriggerRearVIPCarTip,
btnTriggerVehicleBrakes,
@@ -140,10 +142,11 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
break;
}
nBtnTriggerVR.setOnClickListener(new OnClickListener() {
nBtnTriggerVR.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onClick(View v) {
V2XServiceManager.getMoGoStatusManager().setVrMode("nBtnTriggerVR", true);
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
V2XServiceManager.getMoGoStatusManager().setVrMode("nBtnTriggerVR", isChecked);
}
});

View File

@@ -20,6 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="horizontal"
app:alignContent="flex_start"
app:alignItems="center"
@@ -30,9 +31,8 @@
<Button
android:id="@+id/btnTriggerOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_50"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#FFF"
android:padding="@dimen/dp_10"
android:text="隐藏测试按钮面板"
@@ -44,9 +44,8 @@
<Button
android:id="@+id/btnClearRoadEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_50"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#6BCF23"
android:padding="@dimen/dp_10"
android:text="清除缓存播报"
@@ -55,16 +54,16 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
<ToggleButton
android:id="@+id/btnTriggerVR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_50"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#6BCF23"
android:padding="@dimen/dp_10"
android:text="开启VR模式"
android:textColor="#FFFFFF"
android:textOff="开启VR模式"
android:textOn="关闭VR模式"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />