[V2X]道路施工事件添加多边形区域绘制

This commit is contained in:
renwj
2022-08-25 19:34:39 +08:00
parent 9f4bbeee92
commit 115f80a972
10 changed files with 133 additions and 8 deletions

View File

@@ -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)) {

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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();
}
}
}

View File

@@ -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
}

Binary file not shown.

View File

@@ -155,7 +155,7 @@ MOGO_OCH_TAXI_VERSION=2.0.66
# mogoAiCloud sdk services
MOGO_AICLOUD_SERVICES_SDK_VERSION=2.1.16.10
# v2x-sdk
MOGO_V2X_SDK_VERSION=1.4.3.17
MOGO_V2X_SDK_VERSION=1.4.3.20
################# 旧版本架构模块版本 #################

View File

@@ -19,6 +19,7 @@ import java.util.List;
*/
public class MogoPolylineOptions {
public boolean useFacade = false;
private List<MogoLatLng> mPoints;
private float mWidth = 10.0F;
private int mColor = Color.BLACK;
@@ -182,6 +183,12 @@ public class MogoPolylineOptions {
return this;
}
public MogoPolylineOptions useFacade(boolean useFacade) {
this.useFacade = useFacade;
return this;
}
/**
* @param isAboveMaskLayer
* @return
@@ -240,6 +247,11 @@ public class MogoPolylineOptions {
return mIsGradient;
}
public boolean useFacade() {
return useFacade;
}
public float getTransparency() {
return mTransparency;
}

View File

@@ -479,6 +479,7 @@ public class ObjectUtils {
target.zIndex(options.getZIndex());
target.setColor(options.getColor());
target.useGradient(options.isGradient());
target.useFacade(options.useFacade);
if (options.getColorValues() != null) {
target.colorValues(options.getColorValues());
}

View File

@@ -7,6 +7,7 @@ import com.mogo.module.common.enums.EventTypeEnum;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@SuppressWarnings("unused")
@@ -38,6 +39,8 @@ public class MarkerExploreWay implements Serializable {
// 1 需要用户判断是否拥堵 进行UGC问答
private int infoCheckNode;
public Map<String, Object> extras = null;
public String getAddr() {
if (TextUtils.isEmpty(addr)) {
return "未知道路";
@@ -141,6 +144,7 @@ public class MarkerExploreWay implements Serializable {
return infoId;
}
public int getInfoIdInt() {
try {
return Integer.parseInt(infoId);