[V2X][Road]优化道路标记颜色逻辑

[V2X][Road]优化道路标记颜色逻辑2
This commit is contained in:
renwj
2022-09-28 17:22:03 +08:00
parent 86ea6c9d3d
commit 1d0f1422d5
17 changed files with 829 additions and 47878 deletions

View File

@@ -106,14 +106,14 @@ public class BusPassengerMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
}
private void initAMapView() {
@@ -182,7 +182,7 @@ public class BusPassengerMapDirectionView
@Override
public void onLocationChanged(@Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null) {
return;
}

View File

@@ -104,14 +104,14 @@ public class TaxiPassengerMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
}
private void initAMapView() {
@@ -180,7 +180,7 @@ public class TaxiPassengerMapDirectionView
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null){
return;
}

View File

@@ -61,54 +61,54 @@ class RoadAITest {
.setRoadId("200091")
.setLaneNo("-2")
.setTileId("556834853")
.setBearing(156)
.setBearing(90)
.build())
.setPoint(GPSPoint_PB
.newBuilder()
.setLat(26.819533419884188)
.setLon(112.57506466334905)
.setLat(40.20313763799314)
.setLon(116.72844402744953)
.build())
.build())
.addPolygon(0, GPSPoint_PB
.newBuilder()
.setLat(26.819544927961125)
.setLon(112.57503948748804)
.setLat(40.20314863899314)
.setLon(116.72844412744953)
.build())
.addPolygon(1, GPSPoint_PB
.newBuilder()
.setLat(26.81953162903423)
.setLon(112.57503758421541)
.setLat(40.20314563819314)
.setLon(116.72844412744953)
.build())
.addPolygon(2, GPSPoint_PB
.newBuilder()
.setLat(26.81952255026517)
.setLon(112.5750496963295)
.setLat(40.20312263869314)
.setLon(116.72844401744953)
.build())
.addPolygon(3, GPSPoint_PB
.newBuilder()
.setLat(26.819517691652617)
.setLon(112.57507582382465)
.build())
.addPolygon(4, GPSPoint_PB
.newBuilder()
.setLat(26.819521911807858)
.setLon(112.57508983920647)
.build())
.addPolygon(5, GPSPoint_PB
.newBuilder()
.setLat(26.819535210732194)
.setLon(112.57509174248064)
.build())
.addPolygon(6, GPSPoint_PB
.newBuilder()
.setLat(26.81954428950259)
.setLon(112.5750796303722)
.build())
.addPolygon(7, GPSPoint_PB
.newBuilder()
.setLat(26.819549148117684)
.setLon(112.57505350287552)
.setLat(40.20322763889314)
.setLon(116.7284381644953)
.build())
// .addPolygon(4, GPSPoint_PB
// .newBuilder()
// .setLat(26.819521911807858)
// .setLon(112.57508983920647)
// .build())
// .addPolygon(5, GPSPoint_PB
// .newBuilder()
// .setLat(26.819535210732194)
// .setLon(112.57509174248064)
// .build())
// .addPolygon(6, GPSPoint_PB
// .newBuilder()
// .setLat(26.81954428950259)
// .setLon(112.5750796303722)
// .build())
// .addPolygon(7, GPSPoint_PB
// .newBuilder()
// .setLat(26.819549148117684)
// .setLon(112.57505350287552)
// .build())
.addRoad(0, Road_PB
.newBuilder()
.setRoadId("200090")

View File

@@ -11,7 +11,6 @@ import android.text.Html
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.*
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.PopupMenu
import androidx.constraintlayout.widget.ConstraintLayout
@@ -61,7 +60,6 @@ import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.ui.logcatch.ILogViewListener
import com.mogo.eagle.core.function.hmi.ui.logcatch.LogInfoView
import com.mogo.eagle.core.function.hmi.ui.upgrade.UpgradeListAdapter
import com.mogo.eagle.core.network.*
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel
@@ -186,7 +184,7 @@ class DebugSettingView @JvmOverloads constructor(
// 添加 ADAS车辆状态&定位 监听
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
// 添加 地图样式改变 监听
CallerMapLocationListenerManager.addListener(TAG, this)
CallerMapLocationListenerManager.addListener(TAG, this, false)
// 添加 域控制器感知数据 监听
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
// 添加 规划路径相关回调 监听
@@ -221,7 +219,7 @@ class DebugSettingView @JvmOverloads constructor(
// 移除 ADAS车辆状态&定位 监听
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
// 移除 地图样式改变 监听
CallerMapLocationListenerManager.removeListener(TAG)
CallerMapLocationListenerManager.removeListener(TAG, false)
// 移除 域控制器感知数据 监听
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
// 移除 规划路径相关回调 监听
@@ -2014,7 +2012,7 @@ class DebugSettingView @JvmOverloads constructor(
}
}
override fun onLocationChanged(location: MogoLocation?, from: Int) {
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
}
/**

View File

@@ -6,7 +6,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.cloud.passport.IMoGoTokenCallback
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
import com.mogo.eagle.core.data.map.MogoLocation
@@ -46,7 +45,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
private var hasInit = false
override fun init(context: Context?) {
CallerMapLocationListenerManager.addListener(functionName, this)
CallerMapLocationListenerManager.addListener(functionName, this, false)
executor.set(context?.let {
GatherApi.also { itx ->
itx.init(it,
@@ -65,7 +64,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
}
override fun onDestroy() {
CallerMapLocationListenerManager.removeListener("$M_MAP$TAG")
CallerMapLocationListenerManager.removeListener("$M_MAP$TAG", false)
CallerLogger.d("$M_MAP$TAG", "--------- onDestroy --------")
executor.get()?.setOnTaskListener(null)
listeners.clear()
@@ -148,7 +147,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
}
}
override fun onLocationChanged(location: MogoLocation?, from: Int) {
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
location ?: return
executor.get()?.updateLocation(
location.longitude,

View File

@@ -130,7 +130,7 @@ public class AMapCustomView
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
initAMapView(context);
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
//设置全览模式
overLayerView.setOnClickListener(v -> {
displayCustomOverView();
@@ -258,7 +258,7 @@ public class AMapCustomView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG);
}
@@ -269,7 +269,7 @@ public class AMapCustomView
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
mLocation = location;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(location.getLongitude(), location.getLatitude()));
drawCarMarker(location);

View File

@@ -99,14 +99,14 @@ public class SmallMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
}
private void initAMapView() {
@@ -162,7 +162,7 @@ public class SmallMapDirectionView
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null) {
return;
}

View File

@@ -14,7 +14,6 @@ import com.mogo.cloud.passport.IMoGoTokenCallback
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.network.ParamsUtil
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_V2N
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD_SHOW
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CLOUD_V2N
@@ -140,7 +139,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
private fun registerListener() {
V2XManager.addCallback(this)
CallerMapLocationListenerManager.addListener(TAG, this)
CallerMapLocationListenerManager.addListener(TAG, this, false)
BridgeApi.registerCenter()?.let {
it.registerMogoMapListener(MODULE_NAME, this)
it.registerMogoMarkerClickListener(
@@ -160,7 +159,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
private fun unRegisterListener() {
V2XManager.removeCallback(this)
CallerMapLocationListenerManager.removeListener(TAG)
CallerMapLocationListenerManager.removeListener(TAG, false)
BridgeApi.registerCenter()?.let {
it.unregisterMogoMapListener(MODULE_NAME)
it.unregisterMogoMarkerClickListener(ModuleNames.CARD_TYPE_ROAD_CONDITION)
@@ -331,7 +330,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
})
}
override fun onLocationChanged(location: MogoLocation?, from: Int) {
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
location ?: return
BridgeApi.location.set(location)
if (V2XManager.hasInit()) {
@@ -485,7 +484,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
val p = CoordinateUtils.transformWgsToGcj(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0)
l4.lon = p[0]
l4.lat = p[1]
AiRoadMarker.enqueue(Marker(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { d ->
AiRoadMarker.enqueue(Marker(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0, this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { d ->
android.util.Pair(d.lon, d.lat)
}))
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0

View File

@@ -10,7 +10,6 @@ import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import com.mogo.eagle.core.data.map.*
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
import com.mogo.eagle.core.function.api.map.listener.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
import com.mogo.eagle.core.utilcode.kotlin.*
@@ -40,19 +39,19 @@ object AiRoadMarker {
private val overlayManager by lazy { MogoOverlayManager.getInstance() }
private val redLine by lazy { AtomicReference<IMogoPolyline>() }
private val line by lazy { AtomicReference<IMogoPolyline>() }
private val redLineColors = arrayListOf(Color.parseColor("#002ABAD9"), Color.parseColor("#FF7A30"))
private val colors = arrayListOf(Color.parseColor("#002ABAD9"), Color.parseColor("#FF7A30"))
private val markerCache = ConcurrentSet<Marker>()
private val markers = ConcurrentSet<Marker>()
private val redLineOptions by lazy {
private val options by lazy {
MogoPolylineOptions().apply {
zIndex(40000f)
setGps(true)
width(30f)
width(50f)
useGradient(true)
colorValues(redLineColors)
colorValues(colors)
}
}
@@ -70,21 +69,30 @@ object AiRoadMarker {
pool.execute {
var interrupted = false
Log.d(TAG, "--- consumer --- 0 ---")
Logger.d(TAG, "--- consumer --- 0 ---")
while (!interrupted) {
try {
Log.d(TAG, "--- consumer --- 1 ---")
Logger.d(TAG, "--- consumer --- 1 ---")
val top = queue.take() ?: continue
Log.d(TAG, "--- consumer --- 2 ---")
val location = carLocation.get() ?: continue
val isFrontOfCar = isFrontOfCar(top.poi_lon, top.poi_lat, location.first, location.second, location.third)
val isSameRoad = isSameRoad(top.poi_lon, top.poi_lat, location.first, location.second, location.third)
Log.d(TAG, "--- consumer --- 3 ---isFrontOfCar: $isFrontOfCar, isSameRoad: $isSameRoad")
if (isFrontOfCar && isSameRoad) {
Logger.d(TAG, "--- consumer --- 2 ---")
val location = carLocation.get()
if (location == null) {
if (queue.isEmpty()) {
synchronized(markers) {
markers.clear()
}
}
continue
}
val isTrigger = isTriggerEvent(top.poi_lon, top.poi_lat, location.first, location.second, location.third)
Logger.d(TAG, "--- consumer --- 3 ---: isTrigger => $isTrigger")
if (isTrigger) {
marker.set(top)
marker(top)
} else {
markerCache.remove(top)
synchronized(markers) {
markers.remove(top)
}
}
interrupted = Thread.currentThread().isInterrupted
} catch (e: InterruptedException) {
@@ -95,11 +103,12 @@ object AiRoadMarker {
}
}
private fun isSameRoad(x1: Double, y1: Double, x2: Double, y2: Double, angle: Double): Boolean {
val c1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(x1, y1, angle.toFloat(), 500f)
val c2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(x2, y2, angle.toFloat(), 500f)
Log.d(TAG, "isSameRoad--: [$x1, $y1, ${c1.road_id}] ==> [$x2, $y2, ${c2.road_id}]")
return c1 != null && c2 != null && c1.road_id.isNotEmpty() && c1.road_id == c2.road_id
private fun isTriggerEvent(x1: Double, y1: Double, x2: Double, y2: Double, a2: Double): Boolean {
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(x2, y2, x1, y1, a2)
if (angle <= 60 && DrivingDirectionUtils.distance(x1, y1, x2, y2) <= 300) {
return true
}
return false
}
private val onRoadListener = object : OnRoadListener {
@@ -107,7 +116,7 @@ object AiRoadMarker {
private var hasCrossRoad = false
override fun onRoadIdInfo(roadId: String) {
Log.d(TAG, "--- onRoadInfo --- roadId: $roadId")
Logger.d(TAG, "--- onRoadInfo --- roadId: $roadId")
val oldRoadId = this.roadId
if (oldRoadId != roadId) {
if (hasCrossRoad) {
@@ -117,7 +126,7 @@ object AiRoadMarker {
this.roadId = roadId
}
override fun onStopLineInfo(info: StopLine) {
Log.d(TAG, "--- onStopLineInfo --- info: $info")
Logger.d(TAG, "--- onStopLineInfo --- info: $info")
if (!hasCrossRoad) {
hasCrossRoad = true
}
@@ -127,17 +136,17 @@ object AiRoadMarker {
private val onLocationListener = object : IMoGoMapLocationListener {
override fun onLocationChanged(location: MogoLocation?, from: Int) {
if (location == null) {
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
if (location == null || !isGps) {
return
}
try {
val loc = arrayOf(CallerAutoPilotStatusListenerManager.getCurWgs84Lon(), CallerAutoPilotStatusListenerManager.getCurWgs84Lat())
val loc = arrayOf(location.longitude, location.latitude)
carLocation.set(Triple(loc[0], loc[1], location.bearing.toDouble()))
val marker = marker.get() ?: return
val isOutOfRange = isOutOfRange(marker.poi_lon, marker.poi_lat, carLocation.get().first, carLocation.get().second, carLocation.get().third)
if (isOutOfRange) {
Log.d(TAG, "--- onLocationChanged: isOutOfRange --- ")
Logger.d(TAG, "--- onLocationChanged: isOutOfRange --- ")
unMarker(marker)
}
} catch (t: Throwable) {
@@ -148,42 +157,48 @@ object AiRoadMarker {
private fun onCreate() {
CallerMapRoadListenerManager.registerRoadListener(TAG, onRoadListener)
CallerMapLocationListenerManager.addListener(TAG, onLocationListener)
CallerMapLocationListenerManager.addListener(TAG, onLocationListener, true)
}
private fun onDestroy() {
CallerMapRoadListenerManager.unRegisterRoadListener(TAG)
CallerMapLocationListenerManager.removeListener(TAG)
CallerMapLocationListenerManager.removeListener(TAG, true)
pool.shutdownNow()
removeRedLine()
removeLine()
}
fun enqueue(marker: Marker) {
Log.d(TAG, "--- enqueue --- 1 ---")
if (markerCache.contains(marker)) {
Log.d(TAG, "--- enqueue --- cache hit ---")
Logger.d(TAG, "--- enqueue --- 1 ---")
if (markers.contains(marker)) {
Logger.d(TAG, "--- enqueue --- cache hit ---")
return
}
Log.d(TAG, "--- enqueue --- 2 ---")
markerCache += marker
Logger.d(TAG, "--- enqueue --- 2 ---")
synchronized(markers) {
markers += marker
}
pool.execute {
Log.d(TAG, "--- enqueue --- 3 ---${Thread.currentThread().name}::${Thread.currentThread().id}")
Logger.d(TAG, "--- enqueue --- 3 ---${Thread.currentThread().name}::${Thread.currentThread().id}")
queue.put(marker)
}
}
private fun marker(marker: Marker) {
Log.d(TAG, "--- marker --- 1 ---")
val location = carLocation.get() ?: return
Log.d(TAG, "--- marker --- 2 ---")
removeRedLine()
//施工中心点前方的自车行驶方向上300米距离
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f)
//施工中心点后方的自车行驶方向上300米距离
Log.d(TAG, "--- marker --- 3 --- l1: $l1")
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), -300f)
Log.d(TAG, "--- marker --- 4 --- l2: $l2")
if (l1.points.isEmpty() || l2.points.isEmpty()) {
Logger.d(TAG, "--- marker --- 3 --- return ----")
synchronized(markers) {
markers.remove(marker)
}
return
}
Logger.d(TAG, "--- marker --- 4 --- l2: $l2")
val points = LinkedList<MogoLatLng>()
if (l2 != null && l2.points.isNotEmpty()) {
points.addAll(l2.points.reversed().map {
@@ -192,7 +207,7 @@ object AiRoadMarker {
}
val centerX= marker.poi_lon
val centerY = marker.poi_lat
Log.d(TAG, "--- marker --- 5 --- marker: $marker")
Logger.d(TAG, "--- marker --- 5 --- marker: $marker")
val farthestPoint = marker.polygon?.let {
var find: Pair<Double, Double> = Pair(centerX, centerY)
var min = Long.MAX_VALUE
@@ -203,46 +218,53 @@ object AiRoadMarker {
find = p
}
}
MogoLatLng(find.second, find.second)
MogoLatLng(find.second, find.first)
} ?: MogoLatLng(centerY, centerX)
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
Log.d(TAG, "--- marker --- 6 --- marker: $marker")
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
if (l1 != null && l1.points.isNotEmpty()) {
for (l in l1.points) {
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, location.third) < 90L) {
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, location.third + 180) < 90L) {
points.add(l.let { MogoLatLng(it.second, it.first) })
}
}
}
var line = redLine.get()
redLineOptions.points(points)
Log.d(TAG, "--- marker --- 7 --- points: ${points.size}")
if (points.size <= 1) {
synchronized(markers) {
markers.remove(marker)
}
return
}
removeLine()
var line = line.get()
options.points(points)
Logger.d(TAG, "--- marker --- 7 --- points: ${points.size}")
if (line == null || line.isDestroyed) {
val l = overlayManager.addPolyline(redLineOptions)
this.redLine.set(l)
val l = overlayManager.addPolyline(options)
this.line.set(l)
line = l
} else {
line.setOption(redLineOptions)
line.setOption(options)
}
if (!line.isVisible) {
line.isVisible = true
}
}
private fun removeRedLine() {
val old = redLine.get()
Log.d(TAG, "--- removeRedLine --- 1 ---")
private fun removeLine() {
val old = line.get()
Logger.d(TAG, "--- removeRedLine --- 1 ---")
if (old != null) {
Log.d(TAG, "--- removeRedLine --- 2 ---")
redLine.set(null)
Logger.d(TAG, "--- removeRedLine --- 2 ---")
line.set(null)
old.isVisible = false
old.remove()
}
}
private fun unMarker(marker: Marker) {
markerCache -= marker
removeRedLine()
markers -= marker
removeLine()
}
private fun isOutOfRange(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
@@ -257,6 +279,7 @@ object AiRoadMarker {
data class Marker(
val poi_lat: Double,
val poi_lon: Double,
val poi_angle: Double,
val polygon: List<Pair<Double, Double>>?,
var farthestPoint: Pair<Double, Double>? = null
) {

View File

@@ -106,7 +106,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
sV2XWarningMarker.onCarLocationChanged2(location);
}

View File

@@ -13,5 +13,5 @@ interface IMoGoMapLocationListener {
*
* @param location 新定位点
*/
fun onLocationChanged(location: MogoLocation?, from: Int)
fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean)
}

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.call.autopilot
import android.util.*
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
@@ -65,14 +66,18 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
* 获取当前时刻WGS84 lat
*/
fun getCurWgs84Lat(): Double {
return mAutopilotStatusInfo.locationLat
val locationLat = mAutopilotStatusInfo.locationLat
Log.d("GO", "wgs84_lat:" + locationLat)
return locationLat
}
/**
* 获取当前时刻WGS84 lon
*/
fun getCurWgs84Lon(): Double {
return mAutopilotStatusInfo.locationLon
val locationLon = mAutopilotStatusInfo.locationLon
Log.d("GO", "wgs84_lon:" + locationLon)
return locationLon
}
/**

View File

@@ -16,10 +16,19 @@ object CallerMapLocationListenerManager : CallerBase() {
// 记录地图最后一次位置
private var mLocation: MogoLocation? = null
/**
* 记录最后一次高精坐标的位置
*/
private var mGpsLocation: MogoLocation? = null
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mMapStyleChangeListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> =
ConcurrentHashMap()
// 高精坐标回调
private val mGpsChangedListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> = ConcurrentHashMap()
/**
* 获取当前经纬度
*/
@@ -27,44 +36,76 @@ object CallerMapLocationListenerManager : CallerBase() {
return mLocation
}
/**
* 获取当前高精坐标
*/
fun getCurrentGpsLocation(): MogoLocation? {
return mGpsLocation
}
/**
* 添加 地图样式改变 监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addListener(
@Nullable tag: String,
@Nullable listener: IMoGoMapLocationListener
) {
if (mMapStyleChangeListeners.containsKey(tag)) {
return
fun addListener(@Nullable tag: String, @Nullable listener: IMoGoMapLocationListener, isGps: Boolean) {
if (!isGps) {
if (mMapStyleChangeListeners.containsKey(tag)) {
return
}
mMapStyleChangeListeners[tag] = listener
listener.onLocationChanged(mLocation, 0, isGps)
} else {
if (mGpsChangedListeners.containsKey(tag)) {
return
}
mGpsChangedListeners[tag] = listener
listener.onLocationChanged(mGpsLocation, 0, isGps)
}
mMapStyleChangeListeners[tag] = listener
listener.onLocationChanged(mLocation, 0)
}
/**
* 删除 地图样式改变 监听
* @param tag 标记,用来注销监听使用
*/
fun removeListener(@Nullable tag: String) {
if (!mMapStyleChangeListeners.containsKey(tag)) {
return
fun removeListener(@Nullable tag: String, isGps: Boolean) {
if (!isGps) {
if (!mMapStyleChangeListeners.containsKey(tag)) {
return
}
mMapStyleChangeListeners.remove(tag)
} else {
if (!mGpsChangedListeners.containsKey(tag)) {
return
}
mGpsChangedListeners.remove(tag)
}
mMapStyleChangeListeners.remove(tag)
}
/**
* 删除 地图样式改变 监听
* @param listener 要删除的监听对象
*/
fun removeListener(@Nullable listener: IMoGoMapLocationListener) {
if (!mMapStyleChangeListeners.containsValue(listener)) {
return
}
mMapStyleChangeListeners.forEach {
if (it.value == listener) {
mMapStyleChangeListeners.remove(it.key)
fun removeListener(@Nullable listener: IMoGoMapLocationListener, isGps: Boolean) {
if (!isGps) {
if (!mMapStyleChangeListeners.containsValue(listener)) {
return
}
mMapStyleChangeListeners.forEach {
if (it.value == listener) {
mMapStyleChangeListeners.remove(it.key)
}
}
} else {
if (!mGpsChangedListeners.containsValue(listener)) {
return
}
mGpsChangedListeners.forEach {
if (it.value == listener) {
mGpsChangedListeners.remove(it.key)
}
}
}
}
@@ -73,20 +114,25 @@ object CallerMapLocationListenerManager : CallerBase() {
* 触发 地图样式改变 监听
*/
fun invokeMapLocationChangeListener() {
invokeMapLocationChangeListener(mLocation, 0)
invokeMapLocationChangeListener(mLocation, 0, false)
}
/**
* 触发 地图样式改变 监听
* @param location 选中状态
*/
fun invokeMapLocationChangeListener(location: MogoLocation?, from: Int) {
mLocation = location
mMapStyleChangeListeners.forEach {
val tag = it.key
val listener = it.value
listener.onLocationChanged(location, from)
fun invokeMapLocationChangeListener(location: MogoLocation?, from: Int, isGps: Boolean) {
if (!isGps) {
mLocation = location
mMapStyleChangeListeners.forEach {
val listener = it.value
listener.onLocationChanged(location, from, isGps)
}
} else {
mGpsLocation = location
mGpsChangedListeners.forEach {
it.value.onLocationChanged(location, from, isGps)
}
}
}
}

View File

@@ -72,6 +72,7 @@ import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory;
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
@@ -125,6 +126,8 @@ public class AMapViewWrapper implements IMogoMapView,
private boolean mIsFirstLocated = true;
private boolean mIsDelayed = false;
private final LocationListener mGpsLocationListener = location -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(ObjectUtils.fromLocation(location), 0, true);
public AMapViewWrapper(MapAutoView mMapView) {
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--AMapViewWrapper: init");
this.mMapView = mMapView;
@@ -186,7 +189,11 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapLoadedListener(this);
mMapView.setOnMapTouchListener(this);
mMapView.setOnMapClickListener(this);
mMapView.getLocationClient().registerListener(this);
LocationClient client = mMapView.getLocationClient();
if (client != null) {
client.registerListener(this);
client.registerGpsListener(mGpsLocationListener);
}
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
@@ -720,7 +727,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void run() {
if (location != null) {
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(location, 1);
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(location, 1, false);
location = null;
}
}
@@ -734,7 +741,7 @@ public class AMapViewWrapper implements IMogoMapView,
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
MogoLocation currentLocation = ObjectUtils.fromLocation(location);
if (Looper.myLooper() == Looper.getMainLooper()) {
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(currentLocation, 1);
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(currentLocation, 1, false);
} else {
if (mLocationTask == null) {
mLocationTask = new LocationTask();

View File

@@ -116,7 +116,7 @@ public class ALocationClient implements IMogoLocationClient {
}
Trace.beginSection( "timer.onLocationChanged" );
mLastLocation = ObjectUtils.fromLocation( location );
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation, 0));
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation, 0, false));
Set< IMogoLocationListener > listeners = MogoLocationListenerRegister.getInstance().getListeners();
synchronized ( listeners ) {

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@ public class MogoRouteOverlayManager implements
public void init() {
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
}
public static MogoRouteOverlayManager getInstance() {
@@ -68,7 +68,7 @@ public class MogoRouteOverlayManager implements
}
@Override
public void onLocationChanged(@Nullable MogoLocation location, int from) {
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (from != 1 || location == null) {
return;
}