[V2X]道路施工事件添加多边形区域绘制
This commit is contained in:
@@ -49,9 +49,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.flexbox
|
||||
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
// implementation rootProject.ext.dependencies.adasHigh
|
||||
implementation rootProject.ext.dependencies.mogo_v2x
|
||||
implementation rootProject.ext.dependencies.mogoaicloudtrafficlive
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings.System
|
||||
import android.util.*
|
||||
import androidx.core.util.Pair
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.cloud.passport.IMoGoTokenCallback
|
||||
@@ -14,8 +15,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.network.ParamsUtil
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
@@ -472,6 +472,14 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
}
|
||||
})
|
||||
}
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
|
||||
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
|
||||
extra["polygon"] = old.map { d ->
|
||||
val p = CoordinateUtils.transformWgsToGcj(d.lat, d.lon)
|
||||
Pair(p[0], p[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleWarningTargetEvent(data: V2XWarningTarget) {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
|
||||
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay));
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay,markerCardResult.getExtras()));
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,41 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.core.util.Pair;
|
||||
|
||||
import com.google.protobuf.FieldOrBuilder;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.v2x.R;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 道路V2X事件的Marker
|
||||
*/
|
||||
public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
|
||||
private final List<IMogoMarker> pyramids = new ArrayList<>();
|
||||
|
||||
private IMogoPolyline polyline;
|
||||
|
||||
private IMogoOverlayManager overlayManager;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
try {
|
||||
@@ -17,9 +43,74 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (marker != null) {
|
||||
marker.clearAlarmPOI();
|
||||
|
||||
if (entity != null) {
|
||||
marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
if (noveltyInfo != null && noveltyInfo.extras != null && noveltyInfo.extras.containsKey("polygon")) {
|
||||
Object extra = noveltyInfo.extras.get("polygon");
|
||||
if (extra instanceof List) {
|
||||
List l = (List) extra;
|
||||
if (l.size() >= 3) {
|
||||
List<Pair<Double, Double>> polygons = new ArrayList<>();
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
Object o = l.get(i);
|
||||
if (!(o instanceof Pair)) {
|
||||
continue;
|
||||
}
|
||||
Pair p = (Pair) o;
|
||||
Object first = p.first;
|
||||
Object second = p.second;
|
||||
if (first == null || second == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(first instanceof Double) || !(second instanceof Double)) {
|
||||
continue;
|
||||
}
|
||||
polygons.add(Pair.create((Double) first, (Double) second));
|
||||
}
|
||||
|
||||
if (polygons.size() > 0) {
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
Pair<Double, Double> p = polygons.get(i);
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(entity)
|
||||
.latitude(p.second)
|
||||
.longitude(p.first);
|
||||
options.anchor(0.5f, 0.5f);
|
||||
options.icon3DRes(R.raw.sanjiaozhui);
|
||||
try {
|
||||
pyramids.add(MogoMarkerManager.getInstance(BridgeApi.INSTANCE.context()).addMarker("road_pyramid_" + entity.getPoiType(), options));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (polygons.size() > 1) {
|
||||
if (overlayManager == null) {
|
||||
overlayManager = MogoOverlayManager.getInstance();
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(Color.argb(100, 255, 0, 0));
|
||||
colors.add(Color.argb(100, 0, 255, 0));
|
||||
options.colorValues(colors);
|
||||
List<MogoLatLng> points = new ArrayList<>();
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
Pair<Double, Double> p = polygons.get(i);
|
||||
points.add(new MogoLatLng(p.second, p.first));
|
||||
}
|
||||
options.points(points);
|
||||
options.useGradient(true);
|
||||
options.useFacade(true);
|
||||
options.setGps(true);
|
||||
options.width(5f);
|
||||
polyline = overlayManager.addPolyline(options);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -41,5 +132,15 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
// 绘制上次的数据
|
||||
v2xMarker.drawableLastAllPOI();
|
||||
}
|
||||
|
||||
if (polyline != null) {
|
||||
polyline.remove();
|
||||
}
|
||||
if (pyramids.size() > 0) {
|
||||
for (IMogoMarker marker : pyramids) {
|
||||
marker.remove();
|
||||
}
|
||||
pyramids.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? = if (this == null) n
|
||||
it.setAge(this.age)
|
||||
}
|
||||
|
||||
fun V2XMarkerExploreWay.toMarkExploreWay(): MarkerExploreWay = MarkerExploreWay().also {
|
||||
fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map<String, Any>? = null): MarkerExploreWay = MarkerExploreWay().also {
|
||||
it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() }
|
||||
it.userInfo = this.userInfo?.toMarkerUserInfo()
|
||||
it.distance = this.distance
|
||||
@@ -51,4 +51,5 @@ fun V2XMarkerExploreWay.toMarkExploreWay(): MarkerExploreWay = MarkerExploreWay(
|
||||
it.isFabulous = this.isFabulous
|
||||
it.uploadType = this.uploadType
|
||||
it.isCanLive = this.canLive != "0"
|
||||
it.extras = extras
|
||||
}
|
||||
Reference in New Issue
Block a user