[MAP] 高精地图Marker绘制逻辑重构
This commit is contained in:
@@ -7,12 +7,10 @@ import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
@@ -25,8 +23,10 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusStationBean;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
@@ -43,12 +43,9 @@ import com.mogo.och.common.module.utils.QRUtilsKt;
|
||||
import com.mogo.och.common.module.wigets.BindQRCodeDialog;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils;
|
||||
|
||||
@@ -485,20 +482,29 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
CallerLogger.INSTANCE.d(M_BUS + "setMapMaker= "+Thread.currentThread().getName(),
|
||||
uuid + "=latitude=" + lat + ",longitude=" + longi);
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(BusConst.TYPE_MARKER_BUS_ORDER)
|
||||
Point.Options.Builder builder = new Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER)
|
||||
.setId(uuid)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(true)
|
||||
.icon3DRes(resourceId)
|
||||
.latitude(lat)
|
||||
.longitude(longi);
|
||||
IMogoMarker marker = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).addMarker(uuid, options);
|
||||
CenterLine centerLine = CallerMapUIServiceManager.INSTANCE.getMapUIController().getCenterLineInfo(
|
||||
longi,lat,-1);
|
||||
if (null != centerLine && marker != null) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 地图未初始化会返回空
|
||||
marker.setRotateAngle(centerLine.getAngle().floatValue());
|
||||
IMogoMapUIController mapUIController = CallerMapUIServiceManager.INSTANCE.getMapUIController();
|
||||
if (mapUIController != null) {
|
||||
CenterLine centerLine = mapUIController.getCenterLineInfo(
|
||||
longi,lat,-1);
|
||||
if (null != centerLine) { // 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致 地图未初始化会返回空
|
||||
Double angle = centerLine.getAngle();
|
||||
if (angle != null) {
|
||||
builder.rotate(angle.floatValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.showOrUpdatePoint(builder.build());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -508,7 +514,10 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
Runnable removeMapMarkerRunnable = () -> {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "RemoveMapMaker="+Thread.currentThread().getName(),
|
||||
uuid+"=latitude="+lat+",longitude="+longi);
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).removeMarkers(uuid);
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.removePoint(uuid);
|
||||
}
|
||||
};
|
||||
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
|
||||
@@ -17,7 +17,6 @@ import androidx.annotation.RequiresApi;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
@@ -26,8 +25,10 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.map.ICommonNaviChangedCallback;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
@@ -44,7 +45,6 @@ import com.mogo.och.taxi.model.TaxiModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -752,20 +752,29 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "setMapMaker= " + Thread.currentThread().getName(),
|
||||
uuid + "=latitude=" + station.get(1) + ",longitude=" + station.get(0));
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(TaxiConst.TYPE_MARKER_TAXI_ORDER)
|
||||
Point.Options.Builder builder = new Point.Options.Builder(TaxiConst.TYPE_MARKER_TAXI_ORDER, Level.MAP_MARKER)
|
||||
.setId(uuid)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(true)
|
||||
.icon3DRes(resourceId)
|
||||
.latitude(station.get(1))
|
||||
.longitude(station.get(0));
|
||||
IMogoMarker marker = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).addMarker(uuid, options);
|
||||
CenterLine centerLine = CallerMapUIServiceManager.INSTANCE.getMapUIController().getCenterLineInfo(station.get(0)
|
||||
, station.get(1), -1);
|
||||
if (null != centerLine && marker != null) {// 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致
|
||||
marker.setRotateAngle(centerLine.getAngle().floatValue());
|
||||
IMogoMapUIController mapUIController = CallerMapUIServiceManager.INSTANCE.getMapUIController();
|
||||
if (mapUIController != null) {
|
||||
CenterLine centerLine = mapUIController.getCenterLineInfo(station.get(0)
|
||||
, station.get(1), -1);
|
||||
if (null != centerLine) {// 有可能鹰眼map为空没有角度。判空使用后可能造成maker角度跟道路角度不一致
|
||||
Double angle = centerLine.getAngle();
|
||||
if (angle != null) {
|
||||
builder.rotate(angle.floatValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.showOrUpdatePoint(builder.build());
|
||||
}
|
||||
};
|
||||
OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable);
|
||||
@@ -774,7 +783,11 @@ public class TaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment
|
||||
Runnable removeMapMarkerRunnable = () -> {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "RemoveMapMaker=" + Thread.currentThread().getName(),
|
||||
uuid + "=latitude=" + station.get(1) + ",longitude=" + station.get(0));
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).removeMarkers(uuid);
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp())).removeMarkers(uuid);
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.removePoint(uuid);
|
||||
}
|
||||
};
|
||||
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable);
|
||||
}
|
||||
|
||||
@@ -1,88 +1,88 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.util.*
|
||||
import androidx.test.core.app.*
|
||||
import androidx.test.ext.junit.runners.*
|
||||
import androidx.test.filters.*
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.mogo.eagle.core.function.hmi.ui.*
|
||||
import com.mogo.eagle.core.function.main.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.junit.*
|
||||
import org.junit.runner.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import kotlin.Result
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class ApkInstallerTest {
|
||||
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInstall(): Unit = runBlocking {
|
||||
Log.d("RWJ", "wait fragment show ...")
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
delay(10000)
|
||||
|
||||
Log.d("RWJ", "10s end, start install ...")
|
||||
val context = InstrumentationRegistry.getInstrumentation().context
|
||||
ApkInstaller.installApp(f.requireContext(), context.assets.open("190000013.apk")) { code, msg ->
|
||||
Log.d("RWJ", "code: $code, msg: $msg")
|
||||
}
|
||||
Log.d("RWJ", "开始延时10分钟....")
|
||||
delay(TimeUnit.MINUTES.toMillis(10))
|
||||
Log.d("RWJ", "延时10分钟结束....")
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testInstall2(): Unit = runBlocking {
|
||||
Log.d("RWJ", "wait fragment show ...")
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
delay(10000)
|
||||
|
||||
Log.d("RWJ", "10s end, start install ...")
|
||||
val context = InstrumentationRegistry.getInstrumentation().context
|
||||
ApkInstaller.installApp(f.requireContext(), context.assets.open("HelloActivity.zip")) { code, msg ->
|
||||
Log.d("RWJ", "code: $code, msg: $msg")
|
||||
}
|
||||
Log.d("RWJ", "开始延时10分钟....")
|
||||
delay(TimeUnit.MINUTES.toMillis(10))
|
||||
Log.d("RWJ", "延时10分钟结束....")
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.util.*
|
||||
//import androidx.test.core.app.*
|
||||
//import androidx.test.ext.junit.runners.*
|
||||
//import androidx.test.filters.*
|
||||
//import androidx.test.platform.app.InstrumentationRegistry
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.*
|
||||
//import com.mogo.eagle.core.utilcode.util.*
|
||||
//import kotlinx.coroutines.*
|
||||
//import org.junit.*
|
||||
//import org.junit.runner.*
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//import kotlin.Result
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class ApkInstallerTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testInstall(): Unit = runBlocking {
|
||||
// Log.d("RWJ", "wait fragment show ...")
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
// delay(10000)
|
||||
//
|
||||
// Log.d("RWJ", "10s end, start install ...")
|
||||
// val context = InstrumentationRegistry.getInstrumentation().context
|
||||
// ApkInstaller.installApp(f.requireContext(), context.assets.open("190000013.apk")) { code, msg ->
|
||||
// Log.d("RWJ", "code: $code, msg: $msg")
|
||||
// }
|
||||
// Log.d("RWJ", "开始延时10分钟....")
|
||||
// delay(TimeUnit.MINUTES.toMillis(10))
|
||||
// Log.d("RWJ", "延时10分钟结束....")
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testInstall2(): Unit = runBlocking {
|
||||
// Log.d("RWJ", "wait fragment show ...")
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
// delay(10000)
|
||||
//
|
||||
// Log.d("RWJ", "10s end, start install ...")
|
||||
// val context = InstrumentationRegistry.getInstrumentation().context
|
||||
// ApkInstaller.installApp(f.requireContext(), context.assets.open("HelloActivity.zip")) { code, msg ->
|
||||
// Log.d("RWJ", "code: $code, msg: $msg")
|
||||
// }
|
||||
// Log.d("RWJ", "开始延时10分钟....")
|
||||
// delay(TimeUnit.MINUTES.toMillis(10))
|
||||
// Log.d("RWJ", "延时10分钟结束....")
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,148 +1,148 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class AutoPilotBadCaseTest {
|
||||
|
||||
private lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun launch() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance1(): Unit = runBlocking(Dispatchers.Main) {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
delay(TimeUnit.MILLISECONDS.toSeconds(30))
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance2(): Unit = runBlocking(Dispatchers.Main) {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
if (index in 1..4) {
|
||||
delay(TimeUnit.SECONDS.toMillis(15))
|
||||
} else {
|
||||
delay(Random(20).nextLong())
|
||||
}
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance3(): Unit = runBlocking(Dispatchers.Main) {
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.*
|
||||
//import kotlinx.coroutines.flow.*
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import record_cache.RecordPanelOuterClass
|
||||
//import java.text.SimpleDateFormat
|
||||
//import java.util.*
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import kotlin.random.Random
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class AutoPilotBadCaseTest {
|
||||
//
|
||||
// private lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun launch() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance1(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// delay(TimeUnit.MILLISECONDS.toSeconds(30))
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// delay(TimeUnit.SECONDS.toMillis(5))
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance2(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// if (index in 1..4) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(15))
|
||||
// } else {
|
||||
// delay(Random(20).nextLong())
|
||||
// }
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance3(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, TimeUnit.MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,57 +1,57 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.lifecycle.coroutineScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class KotlinCoroutineSchedulersTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinCoroutineSchedulersIo() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
repeat(10) {
|
||||
withContext(Dispatchers.IO) {
|
||||
assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinCoroutineSchedulersCpu() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
repeat(10) {
|
||||
withContext(Dispatchers.Default) {
|
||||
assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.lifecycle.coroutineScope
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.withContext
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class KotlinCoroutineSchedulersTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testKotlinCoroutineSchedulersIo() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
// repeat(10) {
|
||||
// withContext(Dispatchers.IO) {
|
||||
// assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testKotlinCoroutineSchedulersCpu() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
// repeat(10) {
|
||||
// withContext(Dispatchers.Default) {
|
||||
// assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// }
|
||||
//}
|
||||
@@ -1,62 +1,62 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class MapDataCollectTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTaskSent() = runBlocking {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
CallerMapDataCollectorManager.setIsInit()
|
||||
delay(TimeUnit.HOURS.toMillis(1))
|
||||
}
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.annotation.VisibleForTesting
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class MapDataCollectTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testTaskSent() = runBlocking {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// CallerMapDataCollectorManager.setIsInit()
|
||||
// delay(TimeUnit.HOURS.toMillis(1))
|
||||
// }
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,89 +1,89 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.*
|
||||
import androidx.test.ext.junit.runners.*
|
||||
import androidx.test.filters.*
|
||||
import com.mogo.eagle.core.function.hmi.ui.*
|
||||
import com.mogo.eagle.core.function.main.*
|
||||
import com.mogo.launcher.patch.*
|
||||
import com.mogo.launcher.patch.utils.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.junit.*
|
||||
import org.junit.runner.*
|
||||
import java.io.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import kotlin.Result
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class PatchUtilsTest {
|
||||
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testGeneratePatchAndMergeThenInstall() = runBlocking {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
withContext(Dispatchers.Default) {
|
||||
|
||||
|
||||
val context = f.context ?: return@withContext
|
||||
val oldApkPath = context.let {
|
||||
it.packageManager.getPackageInfo(it.packageName, 0)?.applicationInfo?.sourceDir
|
||||
} ?: return@withContext
|
||||
|
||||
val oldApk = File(oldApkPath)
|
||||
if (!oldApk.exists()) {
|
||||
throw AssertionError("old apk file is not exist.")
|
||||
}
|
||||
val oldApkTemp = File(context.getExternalFilesDir(null), "patches/old.apk")
|
||||
if (oldApkTemp.exists()) {
|
||||
oldApkTemp.delete()
|
||||
}
|
||||
oldApkTemp.parentFile?.takeIf { !it.exists() }?.also { it.mkdirs() }
|
||||
|
||||
oldApk.copyTo(oldApkTemp)
|
||||
val patch = File(context.getExternalFilesDir(null), "patches/patch.zip")
|
||||
if (!patch.exists()) {
|
||||
throw AssertionError("patch file is not exist.")
|
||||
}
|
||||
val newApk = File(context.getExternalFilesDir(null), "patches/new.apk")
|
||||
// PatchUtils.applyPatch(context, File(oldApkPath), patch, newApk)
|
||||
// PatchUtils.install(context, newApk)
|
||||
}
|
||||
delay(TimeUnit.MINUTES.toMillis(1))
|
||||
}
|
||||
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.*
|
||||
//import androidx.test.ext.junit.runners.*
|
||||
//import androidx.test.filters.*
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.*
|
||||
//import com.mogo.launcher.patch.*
|
||||
//import com.mogo.launcher.patch.utils.*
|
||||
//import kotlinx.coroutines.*
|
||||
//import org.junit.*
|
||||
//import org.junit.runner.*
|
||||
//import java.io.*
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//import kotlin.Result
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class PatchUtilsTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testGeneratePatchAndMergeThenInstall() = runBlocking {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// withContext(Dispatchers.Default) {
|
||||
//
|
||||
//
|
||||
// val context = f.context ?: return@withContext
|
||||
// val oldApkPath = context.let {
|
||||
// it.packageManager.getPackageInfo(it.packageName, 0)?.applicationInfo?.sourceDir
|
||||
// } ?: return@withContext
|
||||
//
|
||||
// val oldApk = File(oldApkPath)
|
||||
// if (!oldApk.exists()) {
|
||||
// throw AssertionError("old apk file is not exist.")
|
||||
// }
|
||||
// val oldApkTemp = File(context.getExternalFilesDir(null), "patches/old.apk")
|
||||
// if (oldApkTemp.exists()) {
|
||||
// oldApkTemp.delete()
|
||||
// }
|
||||
// oldApkTemp.parentFile?.takeIf { !it.exists() }?.also { it.mkdirs() }
|
||||
//
|
||||
// oldApk.copyTo(oldApkTemp)
|
||||
// val patch = File(context.getExternalFilesDir(null), "patches/patch.zip")
|
||||
// if (!patch.exists()) {
|
||||
// throw AssertionError("patch file is not exist.")
|
||||
// }
|
||||
// val newApk = File(context.getExternalFilesDir(null), "patches/new.apk")
|
||||
//// PatchUtils.applyPatch(context, File(oldApkPath), patch, newApk)
|
||||
//// PatchUtils.install(context, newApk)
|
||||
// }
|
||||
// delay(TimeUnit.MINUTES.toMillis(1))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,426 +1,426 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.animation.Animator
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.eagle.core.data.enums.SidePattern
|
||||
import com.mogo.eagle.core.function.hmi.ui.*
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.ActivityReminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
|
||||
import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.lang.Integer.min
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class ReminderTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderNotOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewUnOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowWarningV2x() = runBlocking {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
|
||||
delay(5000)
|
||||
(1 until 20).map {
|
||||
it
|
||||
}.asFlow()
|
||||
.onEach {
|
||||
f.showWarningV2X("10006", "test", "测试$it", "$it", null, true, 5000)
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(3000000)
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderWhenActivityDestroyed() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
|
||||
if (i == 8) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloat() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val v = View(it).also {
|
||||
it.background = shape(solid = color(i))
|
||||
it.layoutParams = WindowManager.LayoutParams().also { itx ->
|
||||
itx.width = 300
|
||||
itx.height = 400
|
||||
}
|
||||
}
|
||||
val builder = WarningFloat.with(it).setTag("test${i}").setLayout(v).setSidePattern(SidePattern.RESULT_TOP).setCountDownTime(TimeUnit.SECONDS.toMillis(10)).setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110).setImmersionStatusBar(true).addWarningStatusListener(object :
|
||||
IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
}).setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
})
|
||||
Reminder.enqueue(it, WarningFloatReminder(builder))
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testActivityReminder() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testActivityReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameOverrideReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminder() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminder(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminderOverride() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminderOverride(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloatForProject() = runBlocking {
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.animation.Animator
|
||||
//import android.app.Activity
|
||||
//import android.content.Context
|
||||
//import android.content.Intent
|
||||
//import android.graphics.Color
|
||||
//import android.view.Gravity
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//import android.view.WindowManager
|
||||
//import android.view.animation.OvershootInterpolator
|
||||
//import android.widget.PopupWindow
|
||||
//import androidx.core.view.ViewCompat
|
||||
//import androidx.lifecycle.lifecycleScope
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
//import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
//import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
//import com.mogo.eagle.core.data.enums.SidePattern
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
//import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.ActivityReminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
|
||||
//import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
//import kotlinx.coroutines.*
|
||||
//import kotlinx.coroutines.flow.*
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.lang.Integer.min
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class ReminderTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderNotOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val notificationView = V2XNotificationView(it)
|
||||
// notificationView.setWarningIcon(EventTypeEnum.getWarningIcon("10003"))
|
||||
// notificationView.setWarningContent("XXXXXX${i}")
|
||||
// WarningFloat.with(it)
|
||||
// .setTag("tag")
|
||||
// .setLayout(notificationView)
|
||||
// .setSidePattern(SidePattern.RESULT_TOP)
|
||||
// .setCountDownTime(5000)
|
||||
// .setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
// .setImmersionStatusBar(true)
|
||||
// .addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
// override fun onShow() {
|
||||
// }
|
||||
// })
|
||||
// .setAnimator(object : DefaultAnimator() {
|
||||
// override fun enterAnim(
|
||||
// view: View,
|
||||
// params: WindowManager.LayoutParams,
|
||||
// windowManager: WindowManager,
|
||||
// sidePattern: SidePattern
|
||||
// ): Animator? =
|
||||
// super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
// interpolator = OvershootInterpolator()
|
||||
// }
|
||||
//
|
||||
// override fun exitAnim(
|
||||
// view: View,
|
||||
// params: WindowManager.LayoutParams,
|
||||
// windowManager: WindowManager,
|
||||
// sidePattern: SidePattern
|
||||
// ): Animator? =
|
||||
// super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
// })
|
||||
// .show()
|
||||
// delay(2000)
|
||||
// val reminder = WindowManagerViewUnOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
class WarningFloatReminder(private val builder: WarningFloat.Builder) : ViewReminder(builder.config.layoutView!!) {
|
||||
|
||||
override fun show() {
|
||||
builder.show()
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
WarningFloat.dismiss(builder.config.floatTag, false)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewUnOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ActivityNameReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityNameOverrideReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class TestPopupWindowReminder(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
|
||||
override fun show() {
|
||||
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
class TestPopupWindowReminderOverride(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
|
||||
override fun show() {
|
||||
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private fun color(index: Int): Int {
|
||||
if (index > 10) {
|
||||
return Color.BLACK
|
||||
}
|
||||
val alpha = min(255, 255 - index * 20)
|
||||
return Color.argb(alpha, Color.red(Color.RED), Color.green(Color.RED), Color.blue(Color.RED))
|
||||
}
|
||||
}
|
||||
// return@runBlocking
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testShowWarningV2x() = runBlocking {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
//
|
||||
// delay(5000)
|
||||
// (1 until 20).map {
|
||||
// it
|
||||
// }.asFlow()
|
||||
// .onEach {
|
||||
// f.showWarningV2X("10006", "test", "测试$it", "$it", null, true, 5000)
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(3000000)
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// return@runBlocking
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderWhenActivityDestroyed() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
//
|
||||
// if (i == 8) {
|
||||
// it.finish()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testWarningFloat() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val v = View(it).also {
|
||||
// it.background = shape(solid = color(i))
|
||||
// it.layoutParams = WindowManager.LayoutParams().also { itx ->
|
||||
// itx.width = 300
|
||||
// itx.height = 400
|
||||
// }
|
||||
// }
|
||||
// val builder = WarningFloat.with(it).setTag("test${i}").setLayout(v).setSidePattern(SidePattern.RESULT_TOP).setCountDownTime(TimeUnit.SECONDS.toMillis(10)).setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110).setImmersionStatusBar(true).addWarningStatusListener(object :
|
||||
// IMoGoWarningStatusListener {
|
||||
// override fun onShow() {
|
||||
//
|
||||
// }
|
||||
// }).setAnimator(object : DefaultAnimator() {
|
||||
// override fun enterAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
// interpolator = OvershootInterpolator()
|
||||
// }
|
||||
//
|
||||
// override fun exitAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
// })
|
||||
// Reminder.enqueue(it, WarningFloatReminder(builder))
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testActivityReminder() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = ActivityNameReminder(it, "com.mogo.launcher.TestActivity")
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(6))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testActivityReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = ActivityNameOverrideReminder(it, "com.mogo.launcher.TestActivity")
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(6))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testPopupWindowReminder() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
//
|
||||
// val reminder = TestPopupWindowReminder(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
// itx.contentView = View(it).also {
|
||||
// xx -> xx.background = shape(solid = color(i))
|
||||
// xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
// }
|
||||
// })
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testPopupWindowReminderOverride() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
//
|
||||
// val reminder = TestPopupWindowReminderOverride(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
// itx.contentView = View(it).also {
|
||||
// xx -> xx.background = shape(solid = color(i))
|
||||
// xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
// }
|
||||
// })
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testWarningFloatForProject() = runBlocking {
|
||||
//// launch.onActivity {
|
||||
//// it.lifecycleScope.launchWhenResumed {
|
||||
//// for (i in 1..10) {
|
||||
//// val notificationView = V2XNotificationView(it)
|
||||
//// notificationView.setWarningIcon(EventTypeEnum.getWarningIcon("10003"))
|
||||
//// notificationView.setWarningContent("XXXXXX${i}")
|
||||
//// WarningFloat.with(it)
|
||||
//// .setTag("tag")
|
||||
//// .setLayout(notificationView)
|
||||
//// .setSidePattern(SidePattern.RESULT_TOP)
|
||||
//// .setCountDownTime(5000)
|
||||
//// .setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
//// .setImmersionStatusBar(true)
|
||||
//// .addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
//// override fun onShow() {
|
||||
//// }
|
||||
//// })
|
||||
//// .setAnimator(object : DefaultAnimator() {
|
||||
//// override fun enterAnim(
|
||||
//// view: View,
|
||||
//// params: WindowManager.LayoutParams,
|
||||
//// windowManager: WindowManager,
|
||||
//// sidePattern: SidePattern
|
||||
//// ): Animator? =
|
||||
//// super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
//// interpolator = OvershootInterpolator()
|
||||
//// }
|
||||
////
|
||||
//// override fun exitAnim(
|
||||
//// view: View,
|
||||
//// params: WindowManager.LayoutParams,
|
||||
//// windowManager: WindowManager,
|
||||
//// sidePattern: SidePattern
|
||||
//// ): Animator? =
|
||||
//// super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
//// })
|
||||
//// .show()
|
||||
//// delay(2000)
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WarningFloatReminder(private val builder: WarningFloat.Builder) : ViewReminder(builder.config.layoutView!!) {
|
||||
//
|
||||
// override fun show() {
|
||||
// builder.show()
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// WarningFloat.dismiss(builder.config.floatTag, false)
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WindowManagerViewUnOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
//
|
||||
// private val wm by lazy {
|
||||
// content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
// }
|
||||
//
|
||||
// private var isAdd = false
|
||||
//
|
||||
// override fun show() {
|
||||
// if (!isAdd) {
|
||||
// val params = WindowManager.LayoutParams().also {
|
||||
// it.width = width
|
||||
// it.height = height
|
||||
// }
|
||||
// params.gravity = Gravity.CENTER
|
||||
// wm.addView(content, params)
|
||||
// isAdd = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
// wm.removeView(content)
|
||||
// isAdd = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WindowManagerViewOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
//
|
||||
// private val wm by lazy {
|
||||
// content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
// }
|
||||
//
|
||||
// private var isAdd = false
|
||||
//
|
||||
// override fun show() {
|
||||
// if (!isAdd) {
|
||||
// val params = WindowManager.LayoutParams().also {
|
||||
// it.width = width
|
||||
// it.height = height
|
||||
// }
|
||||
// params.gravity = Gravity.CENTER
|
||||
// wm.addView(content, params)
|
||||
// isAdd = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
// wm.removeView(content)
|
||||
// isAdd = false
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class ActivityNameReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
//
|
||||
// override fun show() {
|
||||
// Intent(context, Class.forName(className)).also {
|
||||
// context.startActivity(it)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ActivityNameOverrideReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
//
|
||||
// override fun show() {
|
||||
// Intent(context, Class.forName(className)).also {
|
||||
// context.startActivity(it)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TestPopupWindowReminder(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
//
|
||||
// override fun show() {
|
||||
// popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TestPopupWindowReminderOverride(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
//
|
||||
// override fun show() {
|
||||
// popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun color(index: Int): Int {
|
||||
// if (index > 10) {
|
||||
// return Color.BLACK
|
||||
// }
|
||||
// val alpha = min(255, 255 - index * 20)
|
||||
// return Color.argb(alpha, Color.red(Color.RED), Color.green(Color.RED), Color.blue(Color.RED))
|
||||
// }
|
||||
//}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,54 +1,54 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.os.Debug
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class RxJavaBackPressureTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
RxJavaPlugins.setErrorHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIntervalBackPressure() = runBlocking(Dispatchers.Default) {
|
||||
val subscription = Flowable.interval(50, MILLISECONDS).doOnNext {
|
||||
}.subscribeOn(Schedulers.computation()).observeOn(Schedulers.io()).subscribe {
|
||||
Thread.sleep(2000)
|
||||
}
|
||||
repeat(10) {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
try {
|
||||
Debug.dumpHprofData(Date().toFileName())
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.HOURS.toMillis(1))
|
||||
subscription.dispose()
|
||||
}
|
||||
|
||||
private fun Date.toFileName(): String = SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.getDefault()).format(this) + ".hprof"
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.os.Debug
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import io.reactivex.Flowable
|
||||
//import io.reactivex.plugins.RxJavaPlugins
|
||||
//import io.reactivex.schedulers.Schedulers
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.text.SimpleDateFormat
|
||||
//import java.util.*
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class RxJavaBackPressureTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// RxJavaPlugins.setErrorHandler {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testIntervalBackPressure() = runBlocking(Dispatchers.Default) {
|
||||
// val subscription = Flowable.interval(50, MILLISECONDS).doOnNext {
|
||||
// }.subscribeOn(Schedulers.computation()).observeOn(Schedulers.io()).subscribe {
|
||||
// Thread.sleep(2000)
|
||||
// }
|
||||
// repeat(10) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(5))
|
||||
// try {
|
||||
// Debug.dumpHprofData(Date().toFileName())
|
||||
// } catch (t: Throwable) {
|
||||
// t.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.HOURS.toMillis(1))
|
||||
// subscription.dispose()
|
||||
// }
|
||||
//
|
||||
// private fun Date.toFileName(): String = SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.getDefault()).format(this) + ".hprof"
|
||||
//}
|
||||
@@ -1,76 +1,76 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class RxJavaSchedulersTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaIoSchedulers() = runBlocking {
|
||||
val list = mutableListOf<Int>()
|
||||
for (i in 1..10) {
|
||||
list += i
|
||||
}
|
||||
val result = Observable.fromIterable(list)
|
||||
.doOnNext {
|
||||
assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.reduce(0) { adder, toAdd ->
|
||||
val sum = adder + toAdd
|
||||
sum
|
||||
}
|
||||
.blockingGet()
|
||||
assert(result == 55)
|
||||
|
||||
delay(SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaCpuSchedulers() = runBlocking {
|
||||
val result = Observable.create(ObservableOnSubscribe<Int> { emitter ->
|
||||
for (i in 1..10) {
|
||||
emitter.onNext(i)
|
||||
}
|
||||
assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
emitter.onComplete()
|
||||
}).reduce(0) { adder, toAdd ->
|
||||
adder + toAdd
|
||||
}.subscribeOn(Schedulers.computation()).blockingGet()
|
||||
assert(result == 55)
|
||||
delay(SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaIntervalSchedulers() = runBlocking {
|
||||
var counter = 0
|
||||
Observable.intervalRange(0, 10, 1, 1 ,SECONDS)
|
||||
.doOnNext {
|
||||
counter ++
|
||||
}
|
||||
.subscribe()
|
||||
delay(SECONDS.toMillis(20))
|
||||
assert(counter == 10)
|
||||
}
|
||||
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import io.reactivex.Observable
|
||||
//import io.reactivex.ObservableOnSubscribe
|
||||
//import io.reactivex.schedulers.Schedulers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.TimeUnit.SECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class RxJavaSchedulersTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaIoSchedulers() = runBlocking {
|
||||
// val list = mutableListOf<Int>()
|
||||
// for (i in 1..10) {
|
||||
// list += i
|
||||
// }
|
||||
// val result = Observable.fromIterable(list)
|
||||
// .doOnNext {
|
||||
// assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
// }
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .reduce(0) { adder, toAdd ->
|
||||
// val sum = adder + toAdd
|
||||
// sum
|
||||
// }
|
||||
// .blockingGet()
|
||||
// assert(result == 55)
|
||||
//
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaCpuSchedulers() = runBlocking {
|
||||
// val result = Observable.create(ObservableOnSubscribe<Int> { emitter ->
|
||||
// for (i in 1..10) {
|
||||
// emitter.onNext(i)
|
||||
// }
|
||||
// assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
// emitter.onComplete()
|
||||
// }).reduce(0) { adder, toAdd ->
|
||||
// adder + toAdd
|
||||
// }.subscribeOn(Schedulers.computation()).blockingGet()
|
||||
// assert(result == 55)
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaIntervalSchedulers() = runBlocking {
|
||||
// var counter = 0
|
||||
// Observable.intervalRange(0, 10, 1, 1 ,SECONDS)
|
||||
// .doOnNext {
|
||||
// counter ++
|
||||
// }
|
||||
// .subscribe()
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// assert(counter == 10)
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,71 +1,71 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class TipToastLeakTest {
|
||||
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test() = runBlocking(Dispatchers.Main) {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
while (index < 50) {
|
||||
delay(TimeUnit.SECONDS.toMillis(4))
|
||||
TipToast.shortTip("toast-> $index" )
|
||||
index ++
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
f.activity?.finish()
|
||||
delay(TimeUnit.SECONDS.toMillis(2))
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class TipToastLeakTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun test() = runBlocking(Dispatchers.Main) {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// var index = 0
|
||||
// while (index < 50) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(4))
|
||||
// TipToast.shortTip("toast-> $index" )
|
||||
// index ++
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// f.activity?.finish()
|
||||
// delay(TimeUnit.SECONDS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,74 +1,53 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import android.content.*
|
||||
import android.os.*
|
||||
import android.util.*
|
||||
import androidx.annotation.*
|
||||
import androidx.localbroadcastmanager.content.*
|
||||
import com.mogo.eagle.core.data.config.*
|
||||
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
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.enums.*
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.EventTypeHelper
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.v2x.V2XAdvanceWarning
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.entity.*
|
||||
import com.mogo.eagle.core.data.msgbox.*
|
||||
import com.mogo.eagle.core.data.traffic.*
|
||||
import com.mogo.eagle.core.data.v2x.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.cloud.*
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.*
|
||||
import com.mogo.eagle.core.function.api.map.angle.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.alarm.V2XAlarmServer
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02
|
||||
import com.mogo.eagle.core.function.call.cloud.*
|
||||
import com.mogo.eagle.core.function.call.hmi.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.call.msgbox.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.function.biz.v2x.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.alarm.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_EXTRA_KEY
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_HANDLER_ACTION
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.receiver.SceneBroadcastReceiver
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.V2XScenarioManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.toRoadMarker
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoV2XListener
|
||||
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager
|
||||
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XCallback
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.receiver.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.*
|
||||
import com.zhjt.service.chain.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.*
|
||||
import mogo.telematics.pad.MessagePad.PlanningObject
|
||||
import mogo.v2x.MogoV2X
|
||||
import mogo.v2x.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
IMoGoAutopilotIdentifyListener, IMoGoCloudListener,
|
||||
@@ -80,10 +59,11 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher(TAG))
|
||||
}
|
||||
|
||||
private val mV2XRoadEventEntityArrayList = CopyOnWriteArraySet<V2XRoadEventEntity>()
|
||||
|
||||
private val hasInit by lazy { AtomicBoolean(false) }
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.init(context)
|
||||
if (hasInit.compareAndSet(false, true)) {
|
||||
registerListener()
|
||||
v2xPoiLoader.startLoopPoi()
|
||||
@@ -111,7 +91,6 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
BridgeApi.location.set(mogoLocation)
|
||||
mogoLocation?.let {
|
||||
v2xPoiLoader.updateCheck(mogoLocation.longitude, mogoLocation.latitude)
|
||||
refreshCarState(mogoLocation)
|
||||
@@ -120,9 +99,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
|
||||
private fun refreshCarState(location: MogoLocation) {
|
||||
// 巡航处理
|
||||
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(
|
||||
BridgeApi.v2xMarker()?.v2XRoadEventEntityList, location
|
||||
)
|
||||
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(getV2XRoadEventEntityList(), location)
|
||||
if (v2XRoadEventEntity != null) {
|
||||
val distance = v2XRoadEventEntity.distance
|
||||
val min = if (EventTypeEnumNew.isCloudSocketEvent(v2XRoadEventEntity.poiType)) 0 else 5
|
||||
@@ -144,6 +121,29 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
}
|
||||
}
|
||||
|
||||
private fun getV2XRoadEventEntityList(): CopyOnWriteArrayList<V2XRoadEventEntity> {
|
||||
val roadEventEntities = CopyOnWriteArrayList<V2XRoadEventEntity>() // 当前车辆数据
|
||||
val currentLocation = getChassisLocationGCJ02()
|
||||
for (v2XRoadEventEntity in mV2XRoadEventEntityArrayList) { // 事件位置
|
||||
val location = v2XRoadEventEntity.location
|
||||
if (location != null) {
|
||||
val calculateDistance = CoordinateUtils.calculateLineDistance(location.lat, location.lon, currentLocation.latitude, currentLocation.longitude)
|
||||
v2XRoadEventEntity.distance = calculateDistance.toDouble()
|
||||
}
|
||||
roadEventEntities.add(v2XRoadEventEntity)
|
||||
} // 按照与当前车辆距离排序
|
||||
for (i in roadEventEntities.indices) {
|
||||
for (j in i downTo 1) {
|
||||
if (roadEventEntities[j].distance < roadEventEntities[j - 1].distance) {
|
||||
val v2XRoadEventEntity = roadEventEntities[j - 1]
|
||||
roadEventEntities[j - 1] = roadEventEntities[j]
|
||||
roadEventEntities[j] = v2XRoadEventEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
return roadEventEntities
|
||||
}
|
||||
|
||||
/**
|
||||
* V2XEvent事件回调
|
||||
*/
|
||||
@@ -158,9 +158,6 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
override fun onAck(event: V2XEvent) {
|
||||
Log.d("$M_V2X$TAG", "OK->: $event")
|
||||
when (event) {
|
||||
is V2XEvent.ForwardsWarning -> {
|
||||
handleAdvanceWarningEvent(event)
|
||||
}
|
||||
is V2XEvent.Marker -> {
|
||||
event.data.result?.let {
|
||||
handleRoadMarkerEvent(it)
|
||||
@@ -245,155 +242,35 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
private fun handleRoadMarkerEvent(data: V2XMarkerCardResult) {
|
||||
try {
|
||||
scope.launch(Dispatchers.Default) {
|
||||
BridgeApi.v2xMarker()?.analysisV2XRoadEvent(data)
|
||||
analysisV2XRoadEvent(data)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
//todo 可优化,与obu解析类似
|
||||
private fun handleAdvanceWarningEvent(event: V2XEvent.ForwardsWarning) {
|
||||
scope.launch {
|
||||
val message = event.data
|
||||
val trafficData = buildTrafficData(message)
|
||||
var changeVisualAngle = false
|
||||
when (message.status) {
|
||||
1 -> {
|
||||
var tempAppId = 0
|
||||
var tempTts = ""
|
||||
var tempContent = ""
|
||||
when (message.typeId) {
|
||||
1001 -> {
|
||||
// 弱势交通碰撞预警
|
||||
EventTypeHelper.getVRU { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
private fun analysisV2XRoadEvent(markerCardResult: V2XMarkerCardResult?) {
|
||||
try { //当没有预警提示的时候重新绘制地图POI点
|
||||
if (markerCardResult != null) { // 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
|
||||
mV2XRoadEventEntityArrayList.clear() // 获取探路以及新鲜事儿
|
||||
val exploreWayList = markerCardResult.exploreWay
|
||||
if (exploreWayList != null) {
|
||||
for (markerExploreWay in exploreWayList) {
|
||||
if (isRoadEvent(markerExploreWay.poiType)) {
|
||||
val markerLocation = markerExploreWay.location // 记录道路事件
|
||||
val v2XRoadEventEntity = V2XRoadEventEntity()
|
||||
v2XRoadEventEntity.location = markerLocation // 探路目前只有上报拥堵
|
||||
val poi = markerExploreWay.poiType
|
||||
v2XRoadEventEntity.poiType = poi
|
||||
v2XRoadEventEntity.noveltyInfo = markerExploreWay
|
||||
v2XRoadEventEntity.expireTime = 20000
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity)
|
||||
}
|
||||
1002 -> {
|
||||
// 弱势交通逆行预警
|
||||
EventTypeHelper.getVRURI { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
1003 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_ICW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_ICW.content
|
||||
}
|
||||
1004 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType.toInt()
|
||||
tempTts = String.format(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_BSW.tts,
|
||||
getWarningDirection()
|
||||
)
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_BSW.content
|
||||
}
|
||||
1006 -> {
|
||||
// 逆向超车预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.content
|
||||
}
|
||||
1005 -> {
|
||||
// 闯红灯预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.content
|
||||
}
|
||||
2001 -> {
|
||||
// 最优车道100061
|
||||
EventTypeHelper.getOptLine { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
3001 -> {
|
||||
// 前方道路拥堵预警
|
||||
EventTypeHelper.getTJW { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
}
|
||||
// 不显示弹框,其它保留
|
||||
if (tempContent.isEmpty() || tempTts.isEmpty()) {
|
||||
Log.d("MsgBox-V2XEventManager", "alertContent或ttsContent为空!")
|
||||
}
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts,
|
||||
object : IMoGoWarningStatusListener {
|
||||
val change = changeVisualAngle
|
||||
override fun onShow() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(TooClose)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(Default())
|
||||
}
|
||||
}
|
||||
}, isFromObu = false
|
||||
)
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
2 -> {
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
3 -> {
|
||||
trafficData.uuid?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()?.removeCvxRvInfoIndInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWarningDirection(): String {
|
||||
return "右" //TODO renwj 原来的逻辑,预警方向先写死, 后续做兼容
|
||||
}
|
||||
|
||||
private fun buildTrafficData(message: V2XAdvanceWarning): TrafficData {
|
||||
return TrafficData().apply {
|
||||
type = when (message.objectType) {
|
||||
1 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
|
||||
2 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
|
||||
3 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
|
||||
4 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
|
||||
6 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS
|
||||
8 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK
|
||||
9 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_CAMERA
|
||||
else -> TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
|
||||
}
|
||||
uuid = message.objectId
|
||||
lat = message.position?.lat ?: 0.0
|
||||
lon = message.position?.lon ?: 0.0
|
||||
heading = message.heading ?: 0.0
|
||||
threatLevel = message.threatLevel ?: -1
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.bridge
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
internal object BridgeApi {
|
||||
|
||||
private val context by lazy {
|
||||
AtomicReference<WeakReference<Context>>(null)
|
||||
}
|
||||
|
||||
val location by lazy {
|
||||
AtomicReference<MogoLocation>()
|
||||
}
|
||||
|
||||
private val v2xMarker by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context()) as? IMoGoV2XMarkerManager
|
||||
}
|
||||
|
||||
private val v2xWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xPersonWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoPersonWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xStopPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoStopPolylineManager
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.context.set(WeakReference(context))
|
||||
}
|
||||
|
||||
fun context(): Context = context.get()?.get() ?: Utils.getApp()
|
||||
|
||||
fun v2xMarker() = v2xMarker
|
||||
|
||||
fun v2xWarnPolyline() = v2xWarnPolyline
|
||||
|
||||
fun v2xPersonWarnPolyline() = v2xPersonWarnPolyline
|
||||
|
||||
fun v2xStopPolyline() = v2xStopPolyline
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.consts;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 7:35 PM
|
||||
* desc : 对外服务模块路径
|
||||
* version: 1.0
|
||||
* 使用方式:
|
||||
* Arouter.getInstance().path("").navigate()
|
||||
*/
|
||||
@Keep
|
||||
public class MoGoV2XServicePaths {
|
||||
|
||||
/**
|
||||
* V2X 道路事件POI点
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_MARKER_MANAGER = "/v2xMarkerManager/api";
|
||||
|
||||
|
||||
/**
|
||||
* V2X 道路事件与车辆的连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_WARN_POLYLINE_MANAGER = "/v2xWarnPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 二轮车和行人连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_PERSON_WARN_POLYLINE_MANAGER = "/v2xPersonWarnPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 停止线连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_STOP_POLYLINE_MANAGER = "/v2xStopPolylineManager/api";
|
||||
}
|
||||
@@ -16,10 +16,5 @@ public class V2XConst {
|
||||
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
|
||||
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
|
||||
|
||||
|
||||
/**
|
||||
* V2X预警日志tag
|
||||
*/
|
||||
public static final String LOG_NAME_WARN = "PersonWarn";
|
||||
|
||||
public static final String V2X_MARKER_OWNER = "v2x_road_marker_owner";
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线,
|
||||
*/
|
||||
public interface IMoGoPersonWarnPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,人物和二轮车
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawPersonWarnPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoPersonWarnPolyline();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线
|
||||
*/
|
||||
public interface IMoGoStopPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,目标车,与当前车辆间连线
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawStopPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoStopPolyline();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 8:15 PM
|
||||
* desc : V2X 涉及到的地图 POI 点的绘制
|
||||
* version: 1.0
|
||||
*/
|
||||
public interface IMoGoV2XMarkerManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 获取所有的道路事件点,探路事件,返回结果是按照距离当前车辆从近到远排列好的
|
||||
*
|
||||
* @return 按从近到远排列好的道路事件
|
||||
*/
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList();
|
||||
|
||||
/**
|
||||
* 从探路数据和新鲜事儿的路况信息中解析出道路事件信息
|
||||
*/
|
||||
void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult);
|
||||
|
||||
/**
|
||||
* 绘制正在预警的道路事件的POI点
|
||||
* @param context
|
||||
* @param roadEventEntity
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线
|
||||
*/
|
||||
public interface IMoGoWarnPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,目标车,与当前车辆间连线
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawWarnPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoWarnPolyline();
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绘制行人和二轮车连线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER)
|
||||
public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
|
||||
@Override
|
||||
public void drawPersonWarnPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions().setGps(true);
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
CallerLogger.INSTANCE.d(M_V2X + V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
|
||||
options.width(info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 绘制连接线的对象
|
||||
*/
|
||||
@Override
|
||||
public IMogoPolyline getMogoPersonWarnPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前车辆与道路事件的连接线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER)
|
||||
public class MoGoStopPolylineManager implements IMoGoStopPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
@Override
|
||||
public void drawStopPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions()
|
||||
.setGps(true);
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_V2X + V2XConst.LOG_NAME_WARN, "MoGoStopPolylineManager roadWidth = " + info.getWidth());
|
||||
// 线条粗细,渐变,渐变色值
|
||||
// 当前车辆位置
|
||||
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMogoPolyline getMogoStopPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_NOVELTY;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.marker.V2XMarkerAdapter;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.MapUtils;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 9:57 PM
|
||||
* desc : V2X 涉及到的地图 POI 点的绘制
|
||||
* version: 1.0
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER)
|
||||
public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
private static final String TAG = "MoGoV2XMarkerManager";
|
||||
|
||||
// 记录所有的:新鲜事儿的道路事件点、探路事件
|
||||
private final CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {}
|
||||
|
||||
@Override
|
||||
public CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList() {
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
|
||||
// 当前车辆数据
|
||||
MogoLocation currentLocation = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02();
|
||||
if (currentLocation != null) {
|
||||
// 重新计算距离
|
||||
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {
|
||||
// 事件位置
|
||||
MarkerLocation location = v2XRoadEventEntity.getLocation();
|
||||
if (location != null) {
|
||||
float calculateDistance = CoordinateUtils.calculateLineDistance(location.getLat(), location.getLon(),
|
||||
currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
v2XRoadEventEntity.setDistance(calculateDistance);
|
||||
}
|
||||
roadEventEntities.add(v2XRoadEventEntity);
|
||||
}
|
||||
// 按照与当前车辆距离排序
|
||||
for (int i = 0; i < roadEventEntities.size(); i++) {
|
||||
for (int j = i; j > 0; j--) {
|
||||
if (roadEventEntities.get(j).getDistance() < roadEventEntities.get(j - 1).getDistance()) {
|
||||
V2XRoadEventEntity v2XRoadEventEntity = roadEventEntities.get(j - 1);
|
||||
roadEventEntities.set(j - 1, roadEventEntities.get(j));
|
||||
roadEventEntities.set(j, v2XRoadEventEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return roadEventEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult) {
|
||||
try {
|
||||
//当没有预警提示的时候重新绘制地图POI点
|
||||
if (markerCardResult != null) {
|
||||
// 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
|
||||
mV2XRoadEventEntityArrayList.clear();
|
||||
// 获取探路以及新鲜事儿
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
if (exploreWayList != null) {
|
||||
for (MarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
if (EventTypeEnumNew.isRoadEvent(markerExploreWay.getPoiType())) {
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
// 记录道路事件
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
String poi = markerExploreWay.getPoiType();
|
||||
v2XRoadEventEntity.setPoiType(poi);
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener) {
|
||||
try {
|
||||
// 清除原来的大而全的新鲜事儿
|
||||
if (roadEventEntity.getLocation() != null) {
|
||||
// 道路事件,或者水波纹扩散效果
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.data(roadEventEntity)
|
||||
.latitude(roadEventEntity.getLocation().getLat())
|
||||
.longitude(roadEventEntity.getLocation().getLon());
|
||||
optionsRipple.anchor(0.5f, 0.5f);
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
MarkerExploreWay markerExploreWay = roadEventEntity.getNoveltyInfo();
|
||||
markerShowEntity.setBindObj(markerExploreWay);
|
||||
markerShowEntity.setChecked(false);
|
||||
markerShowEntity.setTextContent(markerExploreWay.getAddr());
|
||||
markerShowEntity.setMarkerLocation(markerExploreWay.getLocation());
|
||||
markerShowEntity.setMarkerType(CARD_TYPE_NOVELTY);
|
||||
optionsRipple.icons(V2XMarkerAdapter.getV2XRoadEventViewGif(context, roadEventEntity));
|
||||
optionsRipple.period(1);
|
||||
IMogoMarker ret = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawMarker(markerShowEntity);
|
||||
// 当前Marker设置为最上面
|
||||
if (ret != null) {
|
||||
ret.setToTop();
|
||||
}
|
||||
// 缩放地图
|
||||
MapUtils.zoomMap(
|
||||
new MogoLatLng(roadEventEntity.getLocation().getLat(),
|
||||
roadEventEntity.getLocation().getLon()
|
||||
), context);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "Location 必须进行初始化!!!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前车辆与道路事件的连接线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER)
|
||||
public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
|
||||
@Override
|
||||
public void drawWarnPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions()
|
||||
.setGps(true);
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
if (info.isHasStopLines()) {
|
||||
colors.add(0x0D3036FF);
|
||||
colors.add(0xD93036FF);
|
||||
colors.add(0x0D3036FF);
|
||||
} else {
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
}
|
||||
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "mMogoPolyline==null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 绘制连接线的对象
|
||||
*/
|
||||
@Override
|
||||
public IMogoPolyline getMogoWarnPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.biz.R;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.view.V2XMarkerRoadEventView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:55
|
||||
* desc : V2X 地图气泡
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XMarkerAdapter {
|
||||
|
||||
/**
|
||||
* 返回道路事件
|
||||
*/
|
||||
public static Bitmap getV2XRoadEventMarkerView(Context context, V2XRoadEventEntity alarmInfo, int imageRes) {
|
||||
return new V2XMarkerRoadEventView(context, alarmInfo).setBackground(imageRes).getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回道路事件gif序列图集合
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventViewGif(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> bitmapArrayList;
|
||||
if (EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_SUGGEST.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_WARNING.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.FOURS_BLOCK_UP.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_CAR_TROUBLE_WARNING.getPoiType().equals(alarmInfo.getPoiType())) {
|
||||
bitmapArrayList = getV2XRoadEventOrangeMarkerView(context, alarmInfo);
|
||||
} else {
|
||||
bitmapArrayList = getV2XRoadEventRedMarkerView(context, alarmInfo);
|
||||
}
|
||||
return bitmapArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回红色扩散效果的序列
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventRedMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> icons = new ArrayList<>();
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00011));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00012));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00013));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00014));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00015));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00016));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00017));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00018));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00019));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00020));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00021));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00022));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00023));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00024));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00025));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00026));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00027));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00028));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00029));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00030));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00031));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00032));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00033));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00034));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00035));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00036));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00037));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00038));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00039));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00040));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00041));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00042));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00043));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00044));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00045));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00046));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00047));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00048));
|
||||
return icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回橘色色扩散效果的序列
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventOrangeMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> icons = new ArrayList<>();
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00011));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00012));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00013));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00014));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00015));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00016));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00017));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00018));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00019));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00020));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00021));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00022));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00023));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00024));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00025));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00026));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00027));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00028));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00029));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00030));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00031));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00032));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00033));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00034));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00035));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00036));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00037));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00038));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00039));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00040));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00041));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00042));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00043));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00044));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00045));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00046));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00047));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00048));
|
||||
return icons;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,11 @@ import android.util.Log
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import kotlinx.coroutines.Runnable
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -17,9 +18,9 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
|
||||
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<IMogoMarker>? = null, var lines: ArrayList<IMogoPolyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<Point>? = null, var lines: ArrayList<Polyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
|
||||
fun addLine(line: IMogoPolyline) {
|
||||
fun addLine(line: Polyline) {
|
||||
var ll = this.lines
|
||||
if (ll == null) {
|
||||
ll = ArrayList()
|
||||
@@ -28,7 +29,7 @@ data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val c
|
||||
ll.add(line)
|
||||
}
|
||||
|
||||
fun addMarker(marker: IMogoMarker) {
|
||||
fun addPoint(marker: Point) {
|
||||
var mm = this.markers
|
||||
if (mm == null) {
|
||||
mm = ArrayList()
|
||||
@@ -72,7 +73,6 @@ object MarkerRemoveManager {
|
||||
private val checkTask = object : Runnable {
|
||||
|
||||
override fun run() {
|
||||
|
||||
try {
|
||||
Log.d(TAG, "--- checkTask --- 1 ---")
|
||||
if (lastCarLocation.get() == null) {
|
||||
@@ -113,8 +113,7 @@ object MarkerRemoveManager {
|
||||
marker.markers?.forEach {
|
||||
try {
|
||||
Log.e(TAG, "--- checkTask --- remove marker: $it, id: ${marker.id}")
|
||||
it.setVisible(false)
|
||||
it.destroy()
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(it.id)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeMarkerError = true
|
||||
@@ -124,9 +123,8 @@ object MarkerRemoveManager {
|
||||
var removeLineError = false
|
||||
marker.lines?.forEach {
|
||||
try {
|
||||
it.isVisible = false
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(it)
|
||||
Log.e(TAG, "--- checkTask --- remove line : $it, id:${marker.id}")
|
||||
it.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeLineError = true
|
||||
@@ -172,9 +170,9 @@ object MarkerRemoveManager {
|
||||
t.printStackTrace()
|
||||
} finally {
|
||||
val gcInfo = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||
lastCarLocation.set((gcInfo?.longitude ?: 0.0) to (gcInfo?.latitude ?: 0.0))
|
||||
lastCarLocation.set(gcInfo.longitude to gcInfo.latitude)
|
||||
val wgsInfo = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
lastGpsLocation.set((wgsInfo?.longitude ?: 0.0) to (wgsInfo?.latitude ?: 0.0))
|
||||
lastGpsLocation.set(wgsInfo.longitude to wgsInfo.latitude)
|
||||
handler.postDelayed(this, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.graphics.Color
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
@@ -14,12 +15,13 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import com.mogo.map.overlay.core.Level.ROAD_CENTER_LINE
|
||||
import com.mogo.map.overlay.line.*
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -47,12 +49,16 @@ class AiRoadMarker {
|
||||
|
||||
private val roadMarker by lazy { V2XAiRoadEventMarker() }
|
||||
|
||||
private val line = AtomicReference<IMogoPolyline>()
|
||||
private val line = AtomicReference<Polyline>()
|
||||
|
||||
private val handler by lazy {
|
||||
Handler(Looper.getMainLooper())
|
||||
}
|
||||
|
||||
private val v2nDrawHandler by lazy {
|
||||
HandlerThread("v2n_draw_thread").let { it.start(); Handler(it.looper)}
|
||||
}
|
||||
|
||||
private val checkExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
@@ -64,128 +70,118 @@ class AiRoadMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private val options by lazy {
|
||||
MogoPolylineOptions().apply {
|
||||
zIndex(40000f)
|
||||
setGps(true)
|
||||
width(50f)
|
||||
useGradient(true)
|
||||
}
|
||||
private val builder by lazy {
|
||||
Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, ROAD_CENTER_LINE).setIsGradient(true).setWidth(50f).setUseGps(true)
|
||||
}
|
||||
|
||||
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false) {
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
|
||||
}
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
300f
|
||||
)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Log.d(TAG, "--- marker --- 3 --- l1:$l1")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", l1)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
-300f
|
||||
)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Log.d(TAG, " --- marker --- 3 --- return ----")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return
|
||||
v2nDrawHandler.post {
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
|
||||
}
|
||||
Log.d(TAG, " --- marker --- 4 --- l2: $l2")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Log.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
centerX,
|
||||
centerY,
|
||||
p.first,
|
||||
p.second,
|
||||
location.heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
if (drawRoadLine) {
|
||||
Log.d(TAG, "--- marker --- 1 ---")
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
300f
|
||||
)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Log.d(TAG, "--- marker --- 3 --- l1:$l1")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", l1)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
-300f
|
||||
)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Log.d(TAG, " --- marker --- 3 --- return ----")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return@post
|
||||
}
|
||||
Log.d(TAG, " --- marker --- 4 --- l2: $l2")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Log.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
centerX,
|
||||
centerY,
|
||||
p.first,
|
||||
p.second,
|
||||
location.heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Log.d(TAG, "--- marker --- 6 --- marker:$marker")
|
||||
V2XBizTrace.onAck("$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.heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Log.d(TAG, "--- marker --- 6 --- marker:$marker")
|
||||
V2XBizTrace.onAck("$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.heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return@post
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
builder.points(points)
|
||||
builder.colors(colors)
|
||||
builder.setVisible(true)
|
||||
Log.d(TAG, "--- marker --- 7 --- points:${points.size}")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
val line = overlayManager?.showOrUpdateLine(builder.build())
|
||||
if (line != null) {
|
||||
this.line.set(line)
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
var line = line.get()
|
||||
options.points(points)
|
||||
options.colorValues(colors)
|
||||
Log.d(TAG, "--- marker --- 7 --- points:${points.size}")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
if (line == null || line.isDestroyed) {
|
||||
val l = overlayManager?.addPolyline(options)
|
||||
this.line.set(l)
|
||||
line = l
|
||||
} else {
|
||||
line.setOption(options)
|
||||
}
|
||||
if (!line.isVisible) {
|
||||
line.isVisible = true
|
||||
}
|
||||
if (line != null) {
|
||||
wrapper.addLine(line)
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
|
||||
private fun removeLine() {
|
||||
@@ -196,19 +192,20 @@ class AiRoadMarker {
|
||||
Log.d(TAG,"--- removeRedLine --- 2")
|
||||
V2XBizTrace.onAck("$TAG --- removeRedLine --- 2", "")
|
||||
line.set(null)
|
||||
old.isVisible = false
|
||||
old.remove()
|
||||
old.delegate?.remove()
|
||||
}
|
||||
}
|
||||
|
||||
private fun unMarker(marker: Marker) {
|
||||
Log.d(TAG,"$TAG --- unMarker ---")
|
||||
V2XBizTrace.onAck("$TAG --- unMarker ---", "")
|
||||
this.marker.set(null)
|
||||
removeLine()
|
||||
roadMarker.removeMarkers()
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
aiMakers.remove(marker.id)
|
||||
v2nDrawHandler.post {
|
||||
Log.d(TAG,"$TAG --- unMarker ---")
|
||||
V2XBizTrace.onAck("$TAG --- unMarker ---", "")
|
||||
this.marker.set(null)
|
||||
removeLine()
|
||||
roadMarker.removeMarkers()
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
aiMakers.remove(marker.id)
|
||||
}
|
||||
}
|
||||
|
||||
fun receive() {
|
||||
|
||||
@@ -5,50 +5,50 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class V2XAiRoadEventMarker {
|
||||
|
||||
private val current = AtomicReference<Pair<IMogoPolyline?, List<IMogoMarker>?>>()
|
||||
|
||||
private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager() }
|
||||
private val current = AtomicReference<Pair<Polyline?, List<Point>?>>()
|
||||
|
||||
fun drawMarkers(entity: V2XRoadEventEntity, wrapper: MarkerWrapper) {
|
||||
val polygon = entity.noveltyInfo.polygon
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)?.also {
|
||||
wrapper.addMarker(it)
|
||||
}
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(
|
||||
Point.Options
|
||||
.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_MARKER)
|
||||
.longitude(entity.location.lon)
|
||||
.latitude(entity.location.lat)
|
||||
.icon3DRes(EventTypeEnumNew.getMarker3DRes(entity.poiType))
|
||||
.set3DMode(true)
|
||||
.build())?.also { wrapper.addPoint(it) }
|
||||
if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) {
|
||||
val options = MogoPolylineOptions()
|
||||
val builder = Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_POLYGON)
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
options.colorValues(colors)
|
||||
builder.colors(colors)
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
|
||||
for (p in polygon) {
|
||||
points.add(MogoLatLng(p.second, p.first))
|
||||
}
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
options.points(points)
|
||||
options.useGradient(true)
|
||||
options.useFacade(true)
|
||||
options.setGps(true)
|
||||
options.width(5f)
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager?.addPolyline(options)
|
||||
builder.points(points)
|
||||
builder.setIsGradient(true)
|
||||
builder.useFacade(true)
|
||||
builder.setUseGps(true)
|
||||
builder.setWidth(5f)
|
||||
builder.setMaxIndex(800000f)
|
||||
builder.setVisible(true)
|
||||
val line = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdateLine(builder.build())
|
||||
line?.let {
|
||||
current.set(Pair(line, wrapper.markers))
|
||||
line.isVisible = true
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
@@ -61,15 +61,15 @@ class V2XAiRoadEventMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun realRemove(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>) {
|
||||
private fun realRemove(pair: Pair<Polyline?, List<Point>?>) {
|
||||
val line = pair.first
|
||||
if (line != null && line.isVisible) {
|
||||
line.remove()
|
||||
if (line != null) {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(line.id)
|
||||
}
|
||||
val markers = pair.second
|
||||
if (markers != null && markers.isNotEmpty()) {
|
||||
for (m in markers) {
|
||||
m.remove()
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(m.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -30,8 +32,8 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
try {
|
||||
// 清除道路事件
|
||||
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (marker != null) {
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
if (entity != null) {
|
||||
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> poiType : ", entity.getPoiType());
|
||||
if (isAiRoadEvent(entity.getPoiType())) {
|
||||
@@ -47,11 +49,16 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker);
|
||||
}
|
||||
} else {
|
||||
IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
if (iMarker != null) {
|
||||
Point point = overlayManager.showOrUpdatePoint(
|
||||
new Point.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_MARKER)
|
||||
.longitude(entity.getLocation().getLon())
|
||||
.latitude(entity.getLocation().getLat())
|
||||
.set3DMode(true)
|
||||
.icon3DRes(EventTypeEnumNew.getMarker3DRes(entity.getPoiType())).build());
|
||||
if (point != null) {
|
||||
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> --- add Marker type: ", entity.getPoiType());
|
||||
ArrayList<IMogoMarker> markers = new ArrayList<>();
|
||||
markers.add(iMarker);
|
||||
ArrayList<Point> markers = new ArrayList<>();
|
||||
markers.add(point);
|
||||
String id = entity.getLocation().getLon() + "_" + entity.getLocation().getLat();
|
||||
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null, null));
|
||||
} else {
|
||||
|
||||
@@ -7,9 +7,7 @@ import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
@@ -25,7 +23,6 @@ import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -37,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChassisLocationGCJ02Listener, IMoGoWarningStatusListener {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
// private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
private V2XWarningTarget mMarkerEntity;
|
||||
|
||||
private WarningDirectionEnum mDirection;
|
||||
@@ -132,7 +129,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChas
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
sV2XWarningMarker.onCarLocationChanged2(gnssInfo);
|
||||
// sV2XWarningMarker.onCarLocationChanged2(gnssInfo);
|
||||
}
|
||||
|
||||
private WarningDirectionEnum getDirection(){
|
||||
|
||||
@@ -1,446 +1,446 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.commons.utils.Trigonometric;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XLocation;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 前方预警marker打点 绘制安全线和预警线 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程,代码保留
|
||||
* @since: 2021/3/30
|
||||
*/
|
||||
public class V2XWarningMarker implements IV2XMarker {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private static final String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
private V2XWarningTarget mCloundWarningInfo;
|
||||
private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
private final List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude(),
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude()
|
||||
);
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
private static long showTime = 6000;
|
||||
private double bearing;
|
||||
private boolean hasStopLines = false;
|
||||
|
||||
@Override
|
||||
public void drawPOI(Object entity) {
|
||||
try {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "===drawPOI");
|
||||
mCloundWarningInfo = (V2XWarningTarget) entity;
|
||||
drawLineWithEntity();
|
||||
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawLineWithEntity() {
|
||||
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
|
||||
fillPointOnStopLine();
|
||||
MogoLocation location = BridgeApi.INSTANCE.getLocation().get();
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
bearing = location.getHeading();
|
||||
|
||||
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
|
||||
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
}
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
if (fillPoints != null && fillPoints.size() > 0) {
|
||||
//存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
//在自车与停止线直线绘制蓝色预警线
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
}
|
||||
//二轮车和行人的渲染和移动
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
}
|
||||
|
||||
/* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//获取停止线前方50m坐标点
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
||||
50, angleForCarMoveDirection());
|
||||
//停止线向前方50m绘制红色预警线
|
||||
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
||||
warningLocation);
|
||||
|
||||
*/
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime());
|
||||
|
||||
//添加停止线marker
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//handleStopLine();
|
||||
}, 0);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "显示时间为++" + showTime + "识别物类型:" +
|
||||
String.valueOf(mCloundWarningInfo.getType()));
|
||||
|
||||
} else { //无停止线
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线");
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
/* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线" + mCloundWarningInfo.toString());
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(mCloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "数据为空carLocation == null");
|
||||
}
|
||||
*/
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon()
|
||||
, mCloundWarningInfo.getLat()
|
||||
, mCloundWarningInfo.getType()
|
||||
, mCloundWarningInfo.getCollisionLat()
|
||||
, mCloundWarningInfo.getCollisionLon()
|
||||
, mCloundWarningInfo.getAngle()
|
||||
, mCloundWarningInfo.getShowTime());
|
||||
}, 0);
|
||||
|
||||
}
|
||||
clearAllLine();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* */
|
||||
public double angleForCarMoveDirection() {
|
||||
MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
|
||||
MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==" + String.valueOf(angle));
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/*绘制停止线前方50m的红色预警线
|
||||
* startLatLng: 划线起点=停止线上的坐标点
|
||||
* mogoLatLng: 停止线前方50m坐标点
|
||||
* */
|
||||
private void drawRedWarningLineFrontOfStopLine(V2XWarningTarget info, MogoLatLng
|
||||
startLatLng, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
|
||||
IMoGoStopPolylineManager stopPolyLineMnager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
if (stopPolyLineMnager != null) {
|
||||
IMogoPolyline polyLine = stopPolyLineMnager.getMogoStopPolyline();
|
||||
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng.lon, startLatLng.lat, 25, angle);
|
||||
if (polyLine != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatLng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.getHeading());
|
||||
CallerLogger.INSTANCE.d(TAG, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
stopPolyLineMnager.drawStopPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
}
|
||||
} else {
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllLine() {
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
|
||||
//清除识别物到碰撞点预警线
|
||||
IMoGoPersonWarnPolylineManager personStopPolyLineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
if (personStopPolyLineManager != null) {
|
||||
personStopPolyLineManager.clearLine();
|
||||
}
|
||||
//清除车前方第一条预警线
|
||||
IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
if (warnPolyLineManager != null) {
|
||||
warnPolyLineManager.clearLine();
|
||||
}
|
||||
//清除停止线
|
||||
IMoGoStopPolylineManager stopPolyLineManager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
if (stopPolyLineManager != null) {
|
||||
stopPolyLineManager.clearLine();
|
||||
}
|
||||
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
//清除小箭头
|
||||
marker.removeMarkers(WARNING_ARROWS);
|
||||
//清除停止线
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}
|
||||
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
public void fillPointOnStopLine() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mCloundWarningInfo.getStopLines();
|
||||
if (stopLines != null && stopLines.size() > 1) {
|
||||
V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
//两点间的距离
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = Trigonometric.getAngle(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线数据不存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "exception : " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 停止线绘制
|
||||
* */
|
||||
private void handleStopLine() {
|
||||
try {
|
||||
if (mCloundWarningInfo != null) {
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}
|
||||
for (int i = 0; i < fillPoints.size(); i++) {
|
||||
V2XWarningTarget entity = new V2XWarningTarget();
|
||||
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
entity.setLat(latLng.lat);
|
||||
entity.setLon(latLng.lon);
|
||||
entity.setHeading(mCloundWarningInfo.getHeading());
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderStopLineMarker(entity.getLon(), entity.getLat());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng.lon, latlng.lat, mCloundWarningInfo.getStopLineDistance(),
|
||||
mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
if (carLocation.lat == 0 || carLocation.lon == 0) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "获取不到车的位置");
|
||||
}
|
||||
MogoLatLng newLocation = new MogoLatLng(0, 0);
|
||||
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().size() > 1) {
|
||||
V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLat(), y.getLat());
|
||||
double angle = Trigonometric.getAngle(x.getLat(), x.getLat(), y.getLon(), y.getLat());
|
||||
newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), distance * 0.5, angle);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线返回坐标点数量不正确" + mCloundWarningInfo.getStopLines().size());
|
||||
}
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存在停止线时自车与停止线之间为蓝色预警
|
||||
* 不存在停止线,自车与预碰撞点之间为红色预警
|
||||
* lon 自车经度
|
||||
* lat 自车纬度
|
||||
*/
|
||||
public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "drawSelfCarLine");
|
||||
if (!isSelfLineClear) {
|
||||
if (mCloundWarningInfo != null) {
|
||||
IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
if (warnPolyLineManager == null) {
|
||||
return;
|
||||
}
|
||||
IMogoPolyline mogoPolyline = warnPolyLineManager.getMogoWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
||||
|
||||
if (!isFirstLocation) {
|
||||
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
isFirstLocation = true;
|
||||
}
|
||||
//绘制线的终点(在停止线上或者预碰撞点上)
|
||||
endLatlng = new MogoLatLng(hasStopLines ?
|
||||
middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
|
||||
middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
|
||||
startLatlng = new MogoLatLng(lat, lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
//扩展点为了渐变色添加
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==扩展点为了渐变色添加:" +
|
||||
String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
info.setLocations(locations);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
if (mCloundWarningInfo.getStopLines() != null) {
|
||||
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
|
||||
}
|
||||
warnPolyLineManager.drawWarnPolyline(BridgeApi.INSTANCE.context(), info);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
} else {
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawOtherObjectLine(V2XWarningTarget info) {
|
||||
if (info != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "info != null");
|
||||
IMoGoPersonWarnPolylineManager personWarnPolylineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
if (personWarnPolylineManager == null) {
|
||||
return;
|
||||
}
|
||||
IMogoPolyline polyLine = personWarnPolylineManager.getMogoPersonWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
|
||||
if (polyLine != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与碰撞点连线 != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.getHeading());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
personWarnPolylineManager.drawPersonWarnPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "info == null");
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
float distance = CoordinateUtils.calculateLineDistance(
|
||||
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
if (distance > 5) {
|
||||
int count = (int) (distance / 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng.getLon(), startLatLng.getLat(), 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "小箭头位置" + newLo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//线随车动
|
||||
public void onCarLocationChanged2(MogoLocation latLng) {
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
if (MogoStatusManager.getInstance().isVrMode() && !isSelfLineClear) {
|
||||
if (mCloundWarningInfo != null) {
|
||||
V2XLocation v2XLocation = new V2XLocation();
|
||||
v2XLocation.setLat(latLng.getLatitude());
|
||||
v2XLocation.setLon(latLng.getLongitude());
|
||||
mCloundWarningInfo.setCarLocation(v2XLocation);
|
||||
}
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "车辆行驶轨迹" + latLng.getLongitude() + "," + latLng.getLatitude());
|
||||
}
|
||||
}
|
||||
//package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
//
|
||||
//import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
//import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
//import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
//
|
||||
//import com.mogo.commons.AbsMogoApplication;
|
||||
//import com.mogo.commons.module.status.MogoStatusManager;
|
||||
//import com.mogo.commons.utils.Trigonometric;
|
||||
//import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
//import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
//import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
//import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
//import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
//import com.mogo.eagle.core.data.v2x.V2XLocation;
|
||||
//import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
//import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
//import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
//import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
//import com.mogo.map.marker.IMogoMarkerManager;
|
||||
//import com.mogo.map.overlay.IMogoPolyline;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * @author liujing
|
||||
// * @description 前方预警marker打点 绘制安全线和预警线 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程,代码保留
|
||||
// * @since: 2021/3/30
|
||||
// */
|
||||
//public class V2XWarningMarker implements IV2XMarker {
|
||||
// private static final String TAG = "V2XWarningMarker";
|
||||
// private static final String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
// private V2XWarningTarget mCloundWarningInfo;
|
||||
// private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
// private final List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
// private boolean isFirstLocation = false;
|
||||
// private MogoLatLng carLocation = new MogoLatLng(
|
||||
// CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude(),
|
||||
// CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude()
|
||||
// );
|
||||
//
|
||||
// /*
|
||||
// * 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
// * */
|
||||
// private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
// private static long showTime = 6000;
|
||||
// private double bearing;
|
||||
// private boolean hasStopLines = false;
|
||||
//
|
||||
// @Override
|
||||
// public void drawPOI(Object entity) {
|
||||
// try {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "===drawPOI");
|
||||
// mCloundWarningInfo = (V2XWarningTarget) entity;
|
||||
// drawLineWithEntity();
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, e.toString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void drawLineWithEntity() {
|
||||
// showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
|
||||
// fillPointOnStopLine();
|
||||
// MogoLocation location = BridgeApi.INSTANCE.getLocation().get();
|
||||
// if (location == null) {
|
||||
// return;
|
||||
// }
|
||||
// bearing = location.getHeading();
|
||||
//
|
||||
// if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
|
||||
// hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
// }
|
||||
// isSelfLineClear = false;
|
||||
// isFirstLocation = false;
|
||||
// if (fillPoints.size() > 0) {
|
||||
// //存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
|
||||
// middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
// //停止线前方画线
|
||||
// WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
// if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
// //在自车与停止线直线绘制蓝色预警线
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
// } else {
|
||||
// }
|
||||
// //二轮车和行人的渲染和移动
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
// }
|
||||
//
|
||||
// /* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //获取停止线前方50m坐标点
|
||||
// MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
||||
// 50, angleForCarMoveDirection());
|
||||
// //停止线向前方50m绘制红色预警线
|
||||
// drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
||||
// warningLocation);
|
||||
//
|
||||
// */
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime());
|
||||
//
|
||||
// //添加停止线marker
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //handleStopLine();
|
||||
// }, 0);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "显示时间为++" + showTime + "识别物类型:" +
|
||||
// String.valueOf(mCloundWarningInfo.getType()));
|
||||
//
|
||||
// } else { //无停止线
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线");
|
||||
// WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
// /* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线" + mCloundWarningInfo.toString());
|
||||
// //绘制识别物与交汇点连线,并且更新连线数据
|
||||
// drawOtherObjectLine(mCloundWarningInfo);
|
||||
// //二轮车和行人的渲染和移动
|
||||
// V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
// if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
// drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "数据为空carLocation == null");
|
||||
// }
|
||||
// */
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon()
|
||||
// , mCloundWarningInfo.getLat()
|
||||
// , mCloundWarningInfo.getType()
|
||||
// , mCloundWarningInfo.getCollisionLat()
|
||||
// , mCloundWarningInfo.getCollisionLon()
|
||||
// , mCloundWarningInfo.getAngle()
|
||||
// , mCloundWarningInfo.getShowTime());
|
||||
// }, 0);
|
||||
//
|
||||
// }
|
||||
// clearAllLine();
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// *
|
||||
// * */
|
||||
// public double angleForCarMoveDirection() {
|
||||
// MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
|
||||
// MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
|
||||
// double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==" + String.valueOf(angle));
|
||||
// return angle;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*绘制停止线前方50m的红色预警线
|
||||
// * startLatLng: 划线起点=停止线上的坐标点
|
||||
// * mogoLatLng: 停止线前方50m坐标点
|
||||
// * */
|
||||
// private void drawRedWarningLineFrontOfStopLine(V2XWarningTarget info, MogoLatLng
|
||||
// startLatLng, MogoLatLng mogoLatLng) {
|
||||
// if (info != null) {
|
||||
// double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
|
||||
// IMoGoStopPolylineManager stopPolyLineMnager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
// if (stopPolyLineMnager != null) {
|
||||
// IMogoPolyline polyLine = stopPolyLineMnager.getMogoStopPolyline();
|
||||
// MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
// MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng.lon, startLatLng.lat, 25, angle);
|
||||
// if (polyLine != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine polyLine != null");
|
||||
// polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
// polyLine.setTransparency(0.5f);
|
||||
// } else {
|
||||
// DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatLng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// lineInfo.setLocations(locations);
|
||||
// lineInfo.setHeading(info.getHeading());
|
||||
// CallerLogger.INSTANCE.d(TAG, "drawStopLine width = " + info.getRoadwidth());
|
||||
// lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
// stopPolyLineMnager.drawStopPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
|
||||
// "中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
// + "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
// }
|
||||
// } else {
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void clearAllLine() {
|
||||
// UiThreadHandler.postDelayed(() -> {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
|
||||
// //清除识别物到碰撞点预警线
|
||||
// IMoGoPersonWarnPolylineManager personStopPolyLineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
// if (personStopPolyLineManager != null) {
|
||||
// personStopPolyLineManager.clearLine();
|
||||
// }
|
||||
// //清除车前方第一条预警线
|
||||
// IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
// if (warnPolyLineManager != null) {
|
||||
// warnPolyLineManager.clearLine();
|
||||
// }
|
||||
// //清除停止线
|
||||
// IMoGoStopPolylineManager stopPolyLineManager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
// if (stopPolyLineManager != null) {
|
||||
// stopPolyLineManager.clearLine();
|
||||
// }
|
||||
//
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// //清除小箭头
|
||||
// marker.removeMarkers(WARNING_ARROWS);
|
||||
// //清除停止线
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
// }
|
||||
//
|
||||
// isSelfLineClear = true;
|
||||
// }, showTime);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 补点后的停止线经纬度合集
|
||||
// */
|
||||
// public void fillPointOnStopLine() {
|
||||
// try {
|
||||
// fillPoints.clear();
|
||||
// List stopLines = mCloundWarningInfo.getStopLines();
|
||||
// if (stopLines != null && stopLines.size() > 1) {
|
||||
// V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
// V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
// //两点间的距离
|
||||
// float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
// float average = distance / 3;
|
||||
// //两点间的角度
|
||||
// double angle = Trigonometric.getAngle(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
// //根据距离和角度获取下个点的经纬度
|
||||
// fillPoints.add(x);
|
||||
// for (int i = 1; i < 3; i++) {
|
||||
// MogoLatLng newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), average * i, angle);
|
||||
// fillPoints.add(newLocation);
|
||||
// }
|
||||
// fillPoints.add(y);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线数据不存在");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// CallerLogger.INSTANCE.e(M_V2X + TAG, "exception : " + e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * 停止线绘制
|
||||
// * */
|
||||
// private void handleStopLine() {
|
||||
// try {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
// }
|
||||
// for (int i = 0; i < fillPoints.size(); i++) {
|
||||
// V2XWarningTarget entity = new V2XWarningTarget();
|
||||
// MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
// entity.setLat(latLng.lat);
|
||||
// entity.setLon(latLng.lon);
|
||||
// entity.setHeading(mCloundWarningInfo.getHeading());
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderStopLineMarker(entity.getLon(), entity.getLat());
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
// MogoLatLng newLocation = Trigonometric.getNewLocation(latlng.lon, latlng.lat, mCloundWarningInfo.getStopLineDistance(),
|
||||
// mCloundWarningInfo.getAngle());
|
||||
// return newLocation;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
// * */
|
||||
// private MogoLatLng getMiddleLocationInStopLine() {
|
||||
// if (carLocation.lat == 0 || carLocation.lon == 0) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "获取不到车的位置");
|
||||
// }
|
||||
// MogoLatLng newLocation = new MogoLatLng(0, 0);
|
||||
// if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().size() > 1) {
|
||||
// V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
// V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
// float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLat(), y.getLat());
|
||||
// double angle = Trigonometric.getAngle(x.getLat(), x.getLat(), y.getLon(), y.getLat());
|
||||
// newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), distance * 0.5, angle);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线返回坐标点数量不正确" + mCloundWarningInfo.getStopLines().size());
|
||||
// }
|
||||
// return newLocation;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 存在停止线时自车与停止线之间为蓝色预警
|
||||
// * 不存在停止线,自车与预碰撞点之间为红色预警
|
||||
// * lon 自车经度
|
||||
// * lat 自车纬度
|
||||
// */
|
||||
// public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "drawSelfCarLine");
|
||||
// if (!isSelfLineClear) {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
// if (warnPolyLineManager == null) {
|
||||
// return;
|
||||
// }
|
||||
// IMogoPolyline mogoPolyline = warnPolyLineManager.getMogoWarnPolyline();
|
||||
// MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
||||
// MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
||||
// MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
||||
//
|
||||
// if (!isFirstLocation) {
|
||||
// carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
// isFirstLocation = true;
|
||||
// }
|
||||
// //绘制线的终点(在停止线上或者预碰撞点上)
|
||||
// endLatlng = new MogoLatLng(hasStopLines ?
|
||||
// middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
|
||||
// middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
//
|
||||
// startLatlng = new MogoLatLng(lat, lon);
|
||||
// float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
// //扩展点为了渐变色添加
|
||||
// addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
// Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==扩展点为了渐变色添加:" +
|
||||
// String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
|
||||
// if (mogoPolyline != null) {
|
||||
// mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
// mogoPolyline.setTransparency(0.5f);
|
||||
// } else {
|
||||
// DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatlng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// info.setLocations(locations);
|
||||
// info.setHeading(bearing);
|
||||
// info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
// if (mCloundWarningInfo.getStopLines() != null) {
|
||||
// info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
|
||||
// }
|
||||
// warnPolyLineManager.drawWarnPolyline(BridgeApi.INSTANCE.context(), info);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
// "中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
// } else {
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
// */
|
||||
// private void drawOtherObjectLine(V2XWarningTarget info) {
|
||||
// if (info != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "info != null");
|
||||
// IMoGoPersonWarnPolylineManager personWarnPolylineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
// if (personWarnPolylineManager == null) {
|
||||
// return;
|
||||
// }
|
||||
// IMogoPolyline polyLine = personWarnPolylineManager.getMogoPersonWarnPolyline();
|
||||
// MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
// MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
// float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
// MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
// Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
|
||||
// if (polyLine != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与碰撞点连线 != null");
|
||||
// polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
// polyLine.setTransparency(0.5f);
|
||||
// } else {
|
||||
// //识别物到预碰撞点之间的箭头
|
||||
// addArrows(startLatlng, endLatlng);
|
||||
// DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatlng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// lineInfo.setLocations(locations);
|
||||
// lineInfo.setHeading(info.getHeading());
|
||||
// lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
// personWarnPolylineManager.drawPersonWarnPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
// }
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.e(M_V2X + TAG, "info == null");
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //侧面目标物与碰撞点之间添加多个小箭头
|
||||
// private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
// float distance = CoordinateUtils.calculateLineDistance(
|
||||
// startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
// if (distance > 5) {
|
||||
// int count = (int) (distance / 5);
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
// startLatLng.getLon(), startLatLng.getLat(), 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "小箭头位置" + newLo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //线随车动
|
||||
// public void onCarLocationChanged2(MogoLocation latLng) {
|
||||
// carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
// if (MogoStatusManager.getInstance().isVrMode() && !isSelfLineClear) {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// V2XLocation v2XLocation = new V2XLocation();
|
||||
// v2XLocation.setLat(latLng.getLatitude());
|
||||
// v2XLocation.setLon(latLng.getLongitude());
|
||||
// mCloundWarningInfo.setCarLocation(v2XLocation);
|
||||
// }
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "车辆行驶轨迹" + latLng.getLongitude() + "," + latLng.getLatitude());
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils
|
||||
|
||||
class MapUtils {
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun zoomMap(latLng: MogoLatLng?, context: Context) {
|
||||
try {
|
||||
if (latLng == null) {
|
||||
return
|
||||
}
|
||||
val mBoundRect = Rect()
|
||||
mBoundRect.bottom = WindowUtils.dip2px(context, 100f)
|
||||
mBoundRect.top = WindowUtils.dip2px(context, 370f)
|
||||
mBoundRect.left = WindowUtils.dip2px(context, 575f)
|
||||
mBoundRect.right = WindowUtils.dip2px(context, 100f)
|
||||
// 当前车辆位置
|
||||
val carLocation = MogoLatLng(
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude,
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude
|
||||
)
|
||||
// 调整自适应的地图镜头
|
||||
CallerMapUIServiceManager.getMapUIController()
|
||||
?.showBounds("MapUtils", carLocation, listOf(latLng), mBoundRect, true)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.obu.*
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.obu.drawer.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
|
||||
@@ -324,8 +325,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
// 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,13 +338,11 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
?.let {
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +361,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
rsmWarningData
|
||||
)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
@@ -381,8 +378,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.call.obu.*
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.obu.drawer.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.Config
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -309,8 +310,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
data.vehBasicsMsg?.let {
|
||||
TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(it)
|
||||
?.let { data ->
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficLocationInfo(data)
|
||||
TrafficMarkerDrawer.updateITrafficLocationInfo(data)
|
||||
}
|
||||
}.also {
|
||||
CallerLogger.e(
|
||||
@@ -570,8 +570,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 更新数据
|
||||
TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,8 +583,8 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
?.let {
|
||||
// 事件结束,还原车辆颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficInfo(it)
|
||||
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -641,8 +640,8 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,13 +654,11 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
?.let {
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,8 +674,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
//更新模型的颜色
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
@@ -695,8 +691,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -953,8 +948,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
CallerObuWarningListenerManager.invokeTrackerWarningInfo(it)
|
||||
}
|
||||
}
|
||||
@@ -965,8 +959,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
CallerObuWarningListenerManager.removeTrackerWarningInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.eagle.core.function.datacenter.obu.const
|
||||
|
||||
class ObuConst {
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
val OBU_MARKER_OWNER = "obu_new_marker_owner"
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.drawer
|
||||
package com.mogo.eagle.core.function.datacenter.obu.drawer
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.DataTypes
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.traffic.threatLevelColor
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.const.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.marker.MogoMarkerOptions
|
||||
import com.mogo.map.overlay.core.Level.MAP_MARKER
|
||||
import com.mogo.map.overlay.point.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ object TrafficMarkerDrawer {
|
||||
private val mMarkerCachesResMd5Values = ConcurrentHashMap<String, String>()
|
||||
|
||||
// 上一帧数据的缓存,用来做移动动画
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, IMogoMarker>()
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, Point?>()
|
||||
|
||||
// 维护一个线程定时轮询数据进行地图绘制
|
||||
private val mDrawerHandler: Handler =
|
||||
@@ -104,7 +104,7 @@ object TrafficMarkerDrawer {
|
||||
if (FunctionBuildConfig.debugTrackerProvider != 1) {
|
||||
return
|
||||
}
|
||||
if (trafficData != null && !TextUtils.isEmpty(trafficData.uuid)) {
|
||||
if (!TextUtils.isEmpty(trafficData.uuid)) {
|
||||
val tempTraffic = mTrafficMap[trafficData.uuid]
|
||||
if (tempTraffic != null) {
|
||||
tempTraffic.lat = trafficData.lat
|
||||
@@ -128,8 +128,8 @@ object TrafficMarkerDrawer {
|
||||
fun removeCvxRvInfoIndInfo(key: String) {
|
||||
if (mTrafficMap.containsKey(key)) {
|
||||
mTrafficMap.remove(key)
|
||||
mMarkersCaches.get(key)?.let {
|
||||
it.remove()
|
||||
mMarkersCaches[key]?.let {
|
||||
it.delegate?.remove()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,8 +141,8 @@ object TrafficMarkerDrawer {
|
||||
private fun drawerTrafficInfo() {
|
||||
// 数据为空的时候清除所有数据
|
||||
if (mTrafficMap.isEmpty()) {
|
||||
mMarkersCaches.forEach {
|
||||
it.value.remove()
|
||||
mMarkersCaches.forEach { it ->
|
||||
it.value?.also { CallerMapUIServiceManager.getOverlayManager()?.removePoint(it) }
|
||||
}
|
||||
mMarkersCaches.clear()
|
||||
} else {
|
||||
@@ -172,40 +172,33 @@ object TrafficMarkerDrawer {
|
||||
TAG,
|
||||
"drawObuRecognizedDataMarker trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
|
||||
)
|
||||
if (trafficData.type != null) {
|
||||
val resId: Int = trafficData.type.traffic3DIconId
|
||||
|
||||
val resIdVal = resId.toString() + ""
|
||||
|
||||
val options = MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(trafficData.heading.toFloat())
|
||||
.position(
|
||||
com.mogo.eagle.core.data.map.MogoLatLng(
|
||||
trafficData.lat,
|
||||
trafficData.lon
|
||||
)
|
||||
)
|
||||
|
||||
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
|
||||
// 修改颜色
|
||||
mMarkersCaches[trafficData.uuid]?.setAnchorColor(trafficData.threatLevelColor())
|
||||
val resId: Int = trafficData.type.traffic3DIconId
|
||||
val resIdVal = resId.toString() + ""
|
||||
val builder = Point.Options.Builder(DataTypes.TYPE_MARKER_ADAS, MAP_MARKER)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(trafficData.heading.toFloat())
|
||||
.longitude(trafficData.lon)
|
||||
.latitude(trafficData.lat)
|
||||
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
|
||||
// 修改颜色
|
||||
mMarkersCaches[trafficData.uuid]?.also {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(it.option.builder().anchorColor(trafficData.threatLevelColor()).build())
|
||||
}
|
||||
val marker = MogoMarkerManager.getInstance(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
}
|
||||
|
||||
// 缓存3D资源
|
||||
mMarkerCachesResMd5Values[resIdVal] = marker.markerResName
|
||||
// 缓存数据
|
||||
if (trafficData.uuid != null) {
|
||||
mMarkersCaches[trafficData.uuid!!] = marker
|
||||
}
|
||||
val options = builder.build()
|
||||
val point = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(options) // val marker = MogoMarkerManager.getInstance(mContext)
|
||||
// .addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
// 缓存3D资源
|
||||
mMarkerCachesResMd5Values[resIdVal] = options.resName ?: "" // 缓存数据
|
||||
if (trafficData.uuid != null) {
|
||||
mMarkersCaches[trafficData.uuid!!] = point
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +206,7 @@ object TrafficMarkerDrawer {
|
||||
* 带动画的修改Marker
|
||||
*/
|
||||
private fun changeDynamicMarker(
|
||||
marker: IMogoMarker,
|
||||
marker: Point,
|
||||
trafficData: TrafficData
|
||||
) {
|
||||
CallerLogger.d(
|
||||
@@ -221,11 +214,12 @@ object TrafficMarkerDrawer {
|
||||
"changeDynamicMarker trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
|
||||
)
|
||||
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
|
||||
mMarkersCaches[trafficData.uuid]?.setAnchorColor(trafficData.threatLevelColor())
|
||||
mMarkersCaches[trafficData.uuid]?.also {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(it.option.builder().anchorColor(trafficData.threatLevelColor()).build())
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
marker.addDynamicAnchorPosition(
|
||||
marker.delegate?.addDynamicAnchorPosition(
|
||||
com.mogo.eagle.core.data.map.MogoLatLng(
|
||||
trafficData.lat,
|
||||
trafficData.lon
|
||||
@@ -5,7 +5,7 @@ import androidx.collection.ArraySet
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -58,14 +58,14 @@ class IdentifyAiCloudDataDrawer : Identify {
|
||||
val key = it.next() as String
|
||||
it.remove()
|
||||
mMarkersCaches.remove(key)
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(key.hashCode().toString())
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.updateBatchAiMarkerPosition(filterList)
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class IdentifyAiCloudDataDrawer : Identify {
|
||||
trafficDataUuidList.clear()
|
||||
mMarkersCaches.forEach { (uuid, _) ->
|
||||
mMarkersCaches.remove(uuid)
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(uuid.hashCode().toString())
|
||||
}
|
||||
mFilterTrafficData.clear()
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
|
||||
@@ -49,7 +49,7 @@ class IdentifyBeautifyDataDrawer : Identify {
|
||||
val filterList = TrackManager.getInstance().filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.updateBatchMarkerPosition(filterList)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import mogo.telematics.pad.MessagePad.PlanningObject
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -82,14 +82,14 @@ class IdentifyOriginDataDrawer : Identify {
|
||||
val key = it.next() as String
|
||||
it.remove()
|
||||
mMarkersCaches.remove(key)
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(key)
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.updateBatchMarkerPosition(filterList)
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class IdentifyOriginDataDrawer : Identify {
|
||||
@SuppressLint("NewApi")
|
||||
override fun clearOldMarker() {
|
||||
for (uuid in trafficDataUuidList) {
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(uuid)
|
||||
}
|
||||
trafficDataUuidList.clear()
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2CellId;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2LatLng;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.identify.MogoIdentifyManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -150,7 +150,7 @@ public class TrackManager {
|
||||
cellIdCaches.remove(key);
|
||||
mMarkersCaches.remove(key);
|
||||
WarningHelper.INSTANCE.remove(key);
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(key);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class TrackManager {
|
||||
WarningHelper.INSTANCE.clear();
|
||||
mMarkersCaches.forEach((uuid, trackObj) -> {
|
||||
trackObj.clear();
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
MogoIdentifyManager.getInstance(AbsMogoApplication.getApp())
|
||||
.removeMarker(uuid);
|
||||
});
|
||||
mMarkersCaches.clear();
|
||||
|
||||
@@ -5,20 +5,16 @@ import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.Pools;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class RouteOverlayDrawer {
|
||||
@@ -27,28 +23,32 @@ public class RouteOverlayDrawer {
|
||||
|
||||
// 连接线参数
|
||||
private Handler mRenderHandler;
|
||||
IMogoOverlayManager mogoOverlayManager;
|
||||
private final IMoGoOverlayManager mogoOverlayManager;
|
||||
private static volatile RouteOverlayDrawer sInstance;
|
||||
private final MogoPolylineOptions mPolylineOptions;
|
||||
private volatile IMogoPolyline mMoGoPolyline;
|
||||
private Polyline.Options mPolylineOptions;
|
||||
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
|
||||
|
||||
|
||||
private RouteOverlayDrawer() {
|
||||
mPolylineOptions = new MogoPolylineOptions();
|
||||
mPolylineOptions.zIndex(75000f);
|
||||
mPolylineOptions.setGps(true);
|
||||
mPolylineOptions.width(20).useGradient(true);
|
||||
// 渐变色
|
||||
mogoOverlayManager = MogoOverlayManager.getInstance();
|
||||
// 线条粗细,渐变,渐变色值
|
||||
HandlerThread renderTask = new HandlerThread("routing_render") {
|
||||
@Override
|
||||
protected void onLooperPrepared() {
|
||||
super.onLooperPrepared();
|
||||
mRenderHandler = new Handler(getLooper());
|
||||
}
|
||||
};
|
||||
renderTask.start();
|
||||
mogoOverlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (mogoOverlayManager != null) {
|
||||
mPolylineOptions = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true)
|
||||
.build();
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
HandlerThread renderTask = new HandlerThread("routing_render") {
|
||||
@Override
|
||||
protected void onLooperPrepared() {
|
||||
super.onLooperPrepared();
|
||||
mRenderHandler = new Handler(getLooper());
|
||||
}
|
||||
};
|
||||
renderTask.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static RouteOverlayDrawer getInstance() {
|
||||
@@ -63,12 +63,11 @@ public class RouteOverlayDrawer {
|
||||
}
|
||||
|
||||
public void clearMogoRouteOverlay() {
|
||||
if (mRenderTask != null) {
|
||||
mRenderHandler.removeCallbacks(mRenderTask);
|
||||
}
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mMoGoPolyline = null;
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mRenderTask != null) {
|
||||
mRenderHandler.removeCallbacks(mRenderTask);
|
||||
}
|
||||
mogoOverlayManager.removeAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +92,14 @@ public class RouteOverlayDrawer {
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void run() {
|
||||
IMoGoOverlayManager overlayManager = mogoOverlayManager;
|
||||
if (overlayManager == null) {
|
||||
return;
|
||||
}
|
||||
LinkedList<MogoLatLng> pps = this.points;
|
||||
boolean isExcept = false;
|
||||
int total;
|
||||
|
||||
try {
|
||||
pps.clear();
|
||||
List<MessagePad.TrajectoryPoint> routes = this.routeList;
|
||||
@@ -170,32 +174,30 @@ public class RouteOverlayDrawer {
|
||||
Strategy strategy = RouteStrategy.INSTANCE.getStrategy();
|
||||
List<Integer> colors = strategy.getColors();
|
||||
boolean isLightOn = strategy instanceof ColorfulStrategy && ((ColorfulStrategy) strategy).isLightOn();
|
||||
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()) {
|
||||
mPolylineOptions.points(points);
|
||||
mPolylineOptions.colorValues(colors);
|
||||
if (isLightOn) {
|
||||
mPolylineOptions.openBright(true);
|
||||
mPolylineOptions.brightColor(COLOR_LIGHT);
|
||||
mPolylineOptions.brightSpeed(0.5f);
|
||||
} else {
|
||||
mPolylineOptions.openBright(false);
|
||||
}
|
||||
mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions);
|
||||
Polyline.Options.Builder builder;
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
} else {
|
||||
mPolylineOptions.points(points);
|
||||
mPolylineOptions.colorValues(colors);
|
||||
if (isLightOn) {
|
||||
mPolylineOptions.openBright(true);
|
||||
mPolylineOptions.brightColor(COLOR_LIGHT);
|
||||
mPolylineOptions.brightSpeed(0.5f);
|
||||
} else {
|
||||
mPolylineOptions.openBright(false);
|
||||
}
|
||||
mMoGoPolyline.setOption(mPolylineOptions);
|
||||
builder = mPolylineOptions.builder();
|
||||
}
|
||||
if (mMoGoPolyline != null && !mMoGoPolyline.isDestroyed() && !mMoGoPolyline.isVisible()) {
|
||||
mMoGoPolyline.setVisible(true);
|
||||
builder.points(points);
|
||||
builder.colors(colors);
|
||||
if (isLightOn) {
|
||||
builder.setLightOn(true);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.5f);
|
||||
} else {
|
||||
builder.setLightOn(false);
|
||||
}
|
||||
builder.setVisible(true);
|
||||
Polyline.Options options = builder.build();
|
||||
if (mPolylineOptions == null) {
|
||||
mPolylineOptions = options;
|
||||
}
|
||||
overlayManager.showOrUpdateLine(options);
|
||||
} else {
|
||||
isExcept = true;
|
||||
}
|
||||
@@ -225,19 +227,25 @@ public class RouteOverlayDrawer {
|
||||
private volatile RenderTask mRenderTask;
|
||||
|
||||
public void drawTrajectoryList(List<MessagePad.TrajectoryPoint> routeList, double bearing) {
|
||||
if (mRenderTask == null) {
|
||||
mRenderTask = new RenderTask();
|
||||
}
|
||||
mRenderTask.setData(routeList, bearing);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mRenderTask);
|
||||
mRenderHandler.post(mRenderTask);
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mRenderTask == null) {
|
||||
mRenderTask = new RenderTask();
|
||||
}
|
||||
mRenderTask.setData(routeList, bearing);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mRenderTask);
|
||||
mRenderHandler.post(mRenderTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
if (mMoGoPolyline != null && !mMoGoPolyline.isDestroyed()) {
|
||||
mMoGoPolyline.setVisible(isVisible);
|
||||
if (mogoOverlayManager != null) {
|
||||
if (isVisible) {
|
||||
mogoOverlayManager.showAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
} else {
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,11 @@ import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.map.IMogoMapService;
|
||||
import com.mogo.eagle.core.function.api.map.marker.IMogoMarkerService;
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager;
|
||||
import com.mogo.map.MoGoOverlayManager;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.location.GDLocationClient;
|
||||
import com.mogo.map.location.IMogoGDLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
/**
|
||||
@@ -25,15 +21,6 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
@Route(path = MogoServicePaths.PATH_SERVICES_MAP)
|
||||
public class MogoMapService implements IMogoMapService {
|
||||
|
||||
@Override
|
||||
public IMogoMarkerManager getMarkerManager(Context context) {
|
||||
return MogoMarkerManager.getInstance(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerService getMarkerService() {
|
||||
return MogoMarkerServiceImpl.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getMapUIController() {
|
||||
@@ -41,8 +28,8 @@ public class MogoMapService implements IMogoMapService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoOverlayManager getOverlayManager() {
|
||||
return MogoOverlayManager.getInstance();
|
||||
public IMoGoOverlayManager getOverlayManager() {
|
||||
return MoGoOverlayManager.INSTANCE.overlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.api.map.marker.IMogoMarkerService;
|
||||
import com.mogo.eagle.core.function.impl.marker.drawer.MarkerDrawer;
|
||||
import com.mogo.eagle.core.function.impl.marker.drawer.TrafficMarkerDrawer;
|
||||
import com.mogo.eagle.core.function.impl.marker.drawer.V2XWarnDataDrawer;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
public class MogoMarkerServiceImpl implements IMogoMarkerService {
|
||||
|
||||
private static volatile MogoMarkerServiceImpl sInstance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
private MogoMarkerServiceImpl() {
|
||||
|
||||
}
|
||||
|
||||
public static MogoMarkerServiceImpl getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (obj) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoMarkerServiceImpl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMogoMarker drawMarker(Object object) {
|
||||
if (object instanceof MarkerShowEntity) {
|
||||
return MarkerDrawer.getInstance().drawMapMarkerImpl(((MarkerShowEntity) object), MarkerDrawer.MARKER_Z_INDEX_HIGH, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWarningMoveMarker(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime) {
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(lon, lat, type, collisionlat, collisionLon, angle, showTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStopLineMarker(double lon, double lat) {
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(lon, lat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawerArrowsMarkerWithLocation(MogoLatLng location, String markerType, int type, int rotate) {
|
||||
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(location, markerType, type, rotate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateITrafficInfo(TrafficData trafficData) {
|
||||
TrafficMarkerDrawer.INSTANCE.updateITrafficInfo(trafficData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateITrafficLocationInfo(TrafficData trafficData) {
|
||||
TrafficMarkerDrawer.INSTANCE.updateITrafficLocationInfo(trafficData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateITrafficThreatLevelInfo(TrafficData trafficData) {
|
||||
TrafficMarkerDrawer.INSTANCE.updateITrafficThreatLevelInfo(trafficData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCvxRvInfoIndInfo(String uuid) {
|
||||
TrafficMarkerDrawer.INSTANCE.removeCvxRvInfoIndInfo(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker;
|
||||
|
||||
public enum AdasRecognizedType {
|
||||
//背景
|
||||
classIdBackground("background", 0),
|
||||
//人
|
||||
classIdPerson("person", 1),
|
||||
//自行车
|
||||
classIdBicycle("bicycle", 2),
|
||||
//小轿车
|
||||
classIdCar("car", 3),
|
||||
//摩托车
|
||||
classIdMoto("moto", 4),
|
||||
//红绿灯
|
||||
classIdTrafficSign("traffic_sign", 5),
|
||||
//bus
|
||||
classIdTrafficBus("traffic_bus", 6),
|
||||
//truck
|
||||
classIdTrafficTruck("traffic_truck", 8),
|
||||
//stopLine
|
||||
classIdStopLine("warning_stop_line", 9),
|
||||
//预警箭头
|
||||
classIdWarningArrows("warning_arrows", 10),
|
||||
|
||||
//未知物体
|
||||
classIdUnKnow("unKnow", 100);
|
||||
|
||||
AdasRecognizedType(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
private String res = "";
|
||||
private int code = -1;
|
||||
|
||||
AdasRecognizedType(String res, int code) {
|
||||
this.res = res;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static AdasRecognizedType[] VAL = {
|
||||
classIdBackground,//0
|
||||
classIdPerson,
|
||||
classIdBicycle,
|
||||
classIdCar,
|
||||
classIdMoto,
|
||||
classIdTrafficSign,
|
||||
classIdTrafficBus,
|
||||
null,
|
||||
classIdTrafficTruck,
|
||||
classIdStopLine,
|
||||
classIdWarningArrows,
|
||||
classIdUnKnow,
|
||||
};
|
||||
|
||||
public String getRes() {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static AdasRecognizedType valueFrom(int code) {
|
||||
if (code == 100) {
|
||||
return classIdUnKnow;
|
||||
}
|
||||
if (code >= 0 && code < VAL.length) {
|
||||
return VAL[code];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.drawer;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.function.impl.marker.AdasRecognizedType;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class BaseDrawer {
|
||||
|
||||
protected final Context mContext;
|
||||
|
||||
public BaseDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取3D锚点模型资源
|
||||
*
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return modelRes
|
||||
*/
|
||||
public int getModelRes(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdCar) {
|
||||
return R.raw.traffic_tachexiaoche;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
|
||||
return R.raw.traffic_daba;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdMoto) {
|
||||
return R.raw.traffic_motuoche;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdStopLine) {
|
||||
return R.raw.stopline;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdWarningArrows) {
|
||||
return R.raw.jiantou;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdUnKnow) {
|
||||
return R.raw.special_vehicle;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdBicycle) {
|
||||
return R.raw.traffic_zixingche;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficTruck) {
|
||||
return R.raw.traffic_daba;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdPerson) {
|
||||
return R.raw.traffic_people;
|
||||
}
|
||||
return R.raw.special_vehicle;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.drawer;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerNoveltyInfo;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerOnlineCar;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShareMusic;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.EmptyMarkerView;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.IMarkerView;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.MapMarkerAdapter;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.OnlineCarMarkerView;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MarkerDrawer {
|
||||
|
||||
public static final int MARKER_Z_INDEX_HIGH = 100;
|
||||
public static final int MARKER_Z_INDEX_LOW = 2;
|
||||
|
||||
private static volatile MarkerDrawer sInstance;
|
||||
|
||||
private MarkerDrawer() {
|
||||
}
|
||||
|
||||
public static MarkerDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (MarkerDrawer.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MarkerDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl(MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener) {
|
||||
return drawMapMarkerImpl(markerShowEntity, false, zIndex, 0, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* add marker, { 如果是需要在3D模式下显示,则需要设置 {@link MogoMarkerOptions icon3DRes 资源id}}
|
||||
*
|
||||
* @param markerShowEntity marker展示数据结构体
|
||||
* @param matchRoadSide 设置是否道路吸附,暂时没用到这个字段
|
||||
* @param zIndex zOrder
|
||||
* @param icon3DRes 3D Res资源
|
||||
* @param listener marker回调
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
public IMogoMarker drawMapMarkerImpl(MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener) {
|
||||
if (markerShowEntity == null || markerShowEntity.getMarkerLocation() == null) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes(icon3DRes).set3DMode(MogoStatusManager.getInstance().isVrMode()).matchOnRoadSide(matchRoadSide).owner(markerShowEntity.getMarkerType()).zIndex(zIndex).data(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
|
||||
if (MogoStatusManager.getInstance().isVrMode()) {
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
if (bindObj instanceof MarkerExploreWay && ((MarkerExploreWay) bindObj).getPoiType() != null) {
|
||||
String poiType = ((MarkerExploreWay) bindObj).getPoiType();
|
||||
options.icon3DRes(EventTypeEnumNew.getMarker3DRes(poiType));
|
||||
}
|
||||
|
||||
}
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(AbsMogoApplication.getApp(), markerShowEntity, options);
|
||||
if (markerView instanceof OnlineCarMarkerView) {
|
||||
try {
|
||||
options.icon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
|
||||
} catch (Exception e) {
|
||||
options.icon(markerView.getBitmap(0));
|
||||
}
|
||||
options.anchor(0.5f, 0.5f);
|
||||
} else {
|
||||
options.icon(markerView.getView());
|
||||
}
|
||||
|
||||
if (options.getIcon3DRes() != 0) {
|
||||
options.icon(new EmptyMarkerView(AbsMogoApplication.getApp()));
|
||||
options.icon(markerView.getBitmap(0));
|
||||
}
|
||||
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
if (marker != null) {
|
||||
marker.setOwner(markerShowEntity.getMarkerType());
|
||||
markerView.setMarker(marker);
|
||||
marker.setOnMarkerClickListener(listener);
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
|
||||
public String getPrimaryKeyFromEntity(Object entity) {
|
||||
if (entity instanceof MarkerExploreWay) {
|
||||
String id = ((MarkerExploreWay) entity).getInfoId();
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return getCarSnFromEntity(entity);
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromMarker(IMogoMarker marker) {
|
||||
if (marker == null || marker.getObject() == null || marker.isDestroyed()) {
|
||||
return null;
|
||||
}
|
||||
if (!(marker.getObject() instanceof MarkerShowEntity)) {
|
||||
return null;
|
||||
}
|
||||
return getPrimaryKeyFromEntity(((MarkerShowEntity) marker.getObject()).getBindObj());
|
||||
}
|
||||
|
||||
private String getCarSnFromEntity(Object entity) {
|
||||
try {
|
||||
if (entity instanceof MarkerOnlineCar) {
|
||||
return ((MarkerOnlineCar) entity).getUserInfo().getSn();
|
||||
} else if (entity instanceof MarkerShareMusic) {
|
||||
return ((MarkerShareMusic) entity).getUserInfo().getSn();
|
||||
} else if (entity instanceof MarkerNoveltyInfo) {
|
||||
return ((MarkerNoveltyInfo) entity).getSn();
|
||||
} else if (entity instanceof MarkerExploreWay) {
|
||||
return ((MarkerExploreWay) entity).getUserInfo().getSn();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 距离半径计算方式
|
||||
*
|
||||
* @param point1 点一坐标
|
||||
* @param point2 点二坐标
|
||||
* @return 两坐标的距离 单位:米(M)
|
||||
*/
|
||||
public static float calculateLineDistance(MogoLatLng point1, MogoLatLng point2) {
|
||||
if (point1 != null && point2 != null) {
|
||||
return calculateLineDistance(point1.lon, point1.lat, point2.lon, point2.lat);
|
||||
} else {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lon1
|
||||
* @param lat1
|
||||
* @param lon2
|
||||
* @param lat2
|
||||
* @return 两坐标的距离 单位:米(M)
|
||||
*/
|
||||
public static float calculateLineDistance(double lon1, double lat1, double lon2, double lat2) {
|
||||
return CoordinateUtils.calculateLineDistance(lon1, lat1, lon2, lat2);
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.drawer;
|
||||
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.IMarkerView;
|
||||
import com.mogo.eagle.core.function.impl.marker.view.MapMarkerAdapter;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
|
||||
/**
|
||||
* 云端 预警数据绘制
|
||||
*/
|
||||
public class V2XWarnDataDrawer extends BaseDrawer {
|
||||
|
||||
private static volatile V2XWarnDataDrawer sInstance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
private V2XWarnDataDrawer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static V2XWarnDataDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (obj) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new V2XWarnDataDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别物移动
|
||||
*/
|
||||
public void renderWarnData(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime) {
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(lat);
|
||||
location.setLon(lon);
|
||||
location.setAngle(angle);
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
IMogoMarker marker = drawMarker(markerShowEntity, modeResType(type));
|
||||
// marker.addDynamicAnchorPosition(new MogoLatLng(collisionlat, collisionLon), (float) heading, showTime * 1000);
|
||||
UiThreadHandler.postDelayed(marker::remove, showTime * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据识别物类型 (行人1/自行车2/摩托车4/骑行车辆11)获取3D模型(对应查看getModelRes)
|
||||
*
|
||||
* @param dataType 数据类型
|
||||
* @return 做完映射后的数据类型
|
||||
*/
|
||||
private int modeResType(int dataType) {
|
||||
switch (dataType) {
|
||||
case 1:
|
||||
case 11:
|
||||
return 1;
|
||||
case 2:
|
||||
return 2;
|
||||
case 4:
|
||||
return 4;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制3D元素
|
||||
*
|
||||
* @param markerShowEntity 要展示的3d数据类型
|
||||
* @param modeResType
|
||||
* @return
|
||||
*/
|
||||
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity, int modeResType) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(markerShowEntity)
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon())
|
||||
.controlAngle(true)
|
||||
.rotate((float) markerShowEntity.getMarkerLocation().getAngle())
|
||||
.setGps(true);
|
||||
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon3DRes(getModelRes(modeResType));
|
||||
options.anchorColor("#FB3C3CFF");
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(mContext).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
iMarkerView.setMarker(marker);
|
||||
marker.setToTop();
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制箭头
|
||||
* @param location
|
||||
* @param markerType
|
||||
* @param type
|
||||
* @param rotate
|
||||
*/
|
||||
public void drawerArrowsMarkerWithLocation(MogoLatLng location, String markerType, int type, int rotate) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.latitude(location.getLat())
|
||||
.longitude(location.getLon())
|
||||
.set3DMode(true)
|
||||
.setGps(true)
|
||||
.controlAngle(true)
|
||||
.icon3DRes(getModelRes(type))
|
||||
.anchorColor("#FB3C3CFF")
|
||||
.flat(true);
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(mContext).addMarker(markerType, options);
|
||||
marker.setRotateAngle(rotate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制停止线 marker
|
||||
*/
|
||||
public void renderStopLineData(double lon, double lat) {
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(lat);
|
||||
location.setLon(lon);
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
IMogoMarker marker = drawStopLineMarker(markerShowEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线绘制
|
||||
*/
|
||||
public IMogoMarker drawStopLineMarker(MarkerShowEntity markerShowEntity) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(markerShowEntity)
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon())
|
||||
.setGps(false);
|
||||
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon3DRes(getModelRes(9));
|
||||
options.anchorColor("#FB3C3CFF");
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(mContext).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
iMarkerView.setMarker(marker);
|
||||
marker.setToTop();
|
||||
return marker;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class EmptyMarkerView extends View implements IMarkerView {
|
||||
|
||||
public EmptyMarkerView( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
|
||||
setMeasuredDimension( 1, 1 );
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-15
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface IMarkerView {
|
||||
|
||||
View getView();
|
||||
|
||||
default Bitmap getBitmap( int type ){
|
||||
return null;
|
||||
}
|
||||
|
||||
void setMarker( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
/**
|
||||
* author : 李小鹏
|
||||
* desc : 地图2dMarker 在3d下的展示
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapCameraInfoView extends MapMarkerBaseView {
|
||||
private String TAG = "MapCameraInfoView";
|
||||
|
||||
private ImageView mCameraImage;
|
||||
|
||||
|
||||
public MapCameraInfoView(Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public MapCameraInfoView(Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
}
|
||||
|
||||
public MapCameraInfoView(Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public MapCameraInfoView(Context context, MogoMarkerOptions options ) {
|
||||
super( context );
|
||||
mOptions = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_camera_layout_info, this );
|
||||
mCameraImage = findViewById( R.id.iv_camera_traffic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateView( MarkerShowEntity markerShowEntity ) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_USER_DATA;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:55
|
||||
* desc : 地图Marker的适配器
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerAdapter {
|
||||
|
||||
/**
|
||||
* 获取 MarkerShowEntity 填充好的 MarkerView
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param markerShowEntity 要填充的数据
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
|
||||
|
||||
if (TextUtils.equals(markerShowEntity.getMarkerType(), CARD_TYPE_USER_DATA)) {
|
||||
return OnlineCarMarkerView.getInstance();
|
||||
} else {
|
||||
if (MogoStatusManager.getInstance().isVrMode()) {
|
||||
return new EmptyMarkerView(context);
|
||||
} else {
|
||||
return new MapMarkerView(context, markerShowEntity, options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.GlideImageLoader;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.imageloader.IMogoImageLoaderListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1310:55
|
||||
* desc : 地图上抽离的Marker的共性
|
||||
* version: 1.0
|
||||
*/
|
||||
public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerView {
|
||||
private String TAG = "MapMarkerBaseView";
|
||||
|
||||
protected Context mContext;
|
||||
protected MogoMarkerOptions mOptions;
|
||||
protected MogoImageView ivUserHead;
|
||||
protected MogoImageView ivIcon;
|
||||
protected ImageView ivCar;
|
||||
protected IMogoMarker mMarker;
|
||||
|
||||
public MapMarkerBaseView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public MapMarkerBaseView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public MapMarkerBaseView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker(IMogoMarker marker) {
|
||||
this.mMarker = marker;
|
||||
}
|
||||
|
||||
protected abstract void initView(Context context);
|
||||
|
||||
public abstract void updateView(MarkerShowEntity markerShowEntity);
|
||||
|
||||
protected void loadImageWithMarker(final MarkerShowEntity markerShowEntity) {
|
||||
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(() -> {
|
||||
runOnUiThread(markerShowEntity);
|
||||
});
|
||||
} else {
|
||||
runOnUiThread(markerShowEntity);
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadPoiTypeIcon(String url, int res) {
|
||||
ivIcon.setImageResource(res);
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(() -> loadPoiTypeIconInUiThread(url, res));
|
||||
} else {
|
||||
loadPoiTypeIconInUiThread(url, res);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPoiTypeIconInUiThread(String url, int res) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setIcon(ViewUtils.fromView(MapMarkerBaseView.this));
|
||||
}
|
||||
if (!url.isEmpty()) {
|
||||
ivIcon.setPlaceHolder(res);
|
||||
ivIcon.setFailureHolder(res);
|
||||
GlideImageLoader.getInstance().displayImage(url,
|
||||
ivIcon, WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
|
||||
new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(Bitmap bitmap) {
|
||||
// 使用view渲染地图marker,刷新纹理的时候,需要重新用view生成纹理,然后在设置
|
||||
if (mMarker != null) {
|
||||
mMarker.setIcon(ViewUtils.fromView(MapMarkerBaseView.this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnUiThread(final MarkerShowEntity markerShowEntity) {
|
||||
if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) {
|
||||
GlideImageLoader.getInstance().displayImage(markerShowEntity.getIconUrl(),
|
||||
ivUserHead,
|
||||
WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
|
||||
new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(Bitmap bitmap) {
|
||||
// 使用view渲染地图marker,刷新纹理的时候,需要重新用view生成纹理,然后在设置
|
||||
if (mMarker != null) {
|
||||
mMarker.setIcon(ViewUtils.fromView(MapMarkerBaseView.this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
ivUserHead.setBackgroundResource(R.drawable.icon_default_user_head);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_ROAD_CONDITION;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.data.map.PoiWrapper;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.eagle.core.data.config.CloudPoiManager;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-0619:55
|
||||
* desc : 地图Marker图标
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerView extends MapMarkerBaseView {
|
||||
private String TAG = "MapMarkerView";
|
||||
|
||||
private FrameLayout clMarkerTopView;
|
||||
private MarkerShowEntity mMarkerShowEntity;
|
||||
|
||||
public MapMarkerView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
|
||||
super( context );
|
||||
mOptions = options;
|
||||
mMarkerShowEntity = markerShowEntity;
|
||||
try {
|
||||
updateView( markerShowEntity );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView( Context context ) {
|
||||
if ( MogoStatusManager.getInstance().isVrMode() ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_vr_layout, this );
|
||||
} else {
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout, this );
|
||||
}
|
||||
clMarkerTopView = findViewById( R.id.clMarkerTopView );
|
||||
ivIcon = findViewById( R.id.ivIcon );
|
||||
ivCar = findViewById( R.id.ivCar );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateView( MarkerShowEntity markerShowEntity ) {
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
switch ( markerShowEntity.getMarkerType() ) {
|
||||
case CARD_TYPE_ROAD_CONDITION:
|
||||
if ( mMarkerShowEntity != null && mMarkerShowEntity.isChecked() ) {
|
||||
clMarkerTopView.setBackgroundResource( R.drawable.module_services_marker_vr_bkg_checked );
|
||||
}
|
||||
if ( bindObj instanceof MarkerExploreWay && ( ( MarkerExploreWay ) bindObj ).getPoiType() != null ) {
|
||||
// 根据poiType获取对应的图片
|
||||
String poiType = ( ( MarkerExploreWay ) bindObj ).getPoiType();
|
||||
PoiWrapper poiWrapper =
|
||||
CloudPoiManager.getInstance().getWrapperByPoiType( poiType );
|
||||
if ( poiWrapper != null ) {
|
||||
// 加载图片
|
||||
loadPoiTypeIcon( poiWrapper.getIconUrl(), poiWrapper.getIconRes() );
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e( TAG, "未能根据poiType获取对应poi信息,无法渲染marker====" + poiType );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.mogo.eagle.core.function.impl.marker.view;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnlineCarMarkerView implements IMarkerView {
|
||||
|
||||
private static Map< Integer, SoftReference< Bitmap > > sRef = new HashMap<>();
|
||||
|
||||
private OnlineCarMarkerView() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
|
||||
}
|
||||
|
||||
public static OnlineCarMarkerView getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap( int vehicleType ) {
|
||||
if ( sRef.get( vehicleType ) == null || sRef.get( vehicleType ).get() == null
|
||||
|| sRef.get( vehicleType ).get().isRecycled() ) {
|
||||
switch ( vehicleType ) {
|
||||
case 5:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_taxi ) ) );
|
||||
break;
|
||||
case 6:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_bus ) ) );
|
||||
break;
|
||||
case 1:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_110 ) ) );
|
||||
break;
|
||||
case 2:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_120 ) ) );
|
||||
break;
|
||||
case 7:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_119 ) ) );
|
||||
break;
|
||||
default:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) );
|
||||
}
|
||||
}
|
||||
return sRef.get( vehicleType ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,8 @@ package com.mogo.eagle.core.function.api.map;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.function.api.map.marker.IMogoMarkerService;
|
||||
import com.mogo.map.location.IMogoGDLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
/**
|
||||
@@ -16,19 +14,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
* 地图对外接口
|
||||
*/
|
||||
public interface IMogoMapService extends IProvider {
|
||||
/**
|
||||
* marker 操作
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerManager getMarkerManager(Context context);
|
||||
|
||||
/**
|
||||
* 带有业务标注的服务marker
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerService getMarkerService();
|
||||
|
||||
|
||||
/**
|
||||
* 地图UI控制
|
||||
@@ -37,12 +24,12 @@ public interface IMogoMapService extends IProvider {
|
||||
*/
|
||||
IMogoMapUIController getMapUIController();
|
||||
|
||||
|
||||
/**
|
||||
* 覆盖物操作
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoOverlayManager getOverlayManager();
|
||||
IMoGoOverlayManager getOverlayManager();
|
||||
|
||||
/**
|
||||
* 获取高德定位服务
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.mogo.eagle.core.function.api.map.marker;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
|
||||
public interface IMogoMarkerService {
|
||||
|
||||
/**
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
IMogoMarker drawMarker(Object object);
|
||||
|
||||
/**
|
||||
* 识别物体移动
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @param type
|
||||
* @param collisionlat
|
||||
* @param collisionLon
|
||||
* @param angle
|
||||
* @param showTime
|
||||
*/
|
||||
void renderWarningMoveMarker(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime);
|
||||
|
||||
/**
|
||||
* 绘制停止线marker
|
||||
* @param lon
|
||||
* @param lat
|
||||
*/
|
||||
void renderStopLineMarker(double lon, double lat);
|
||||
|
||||
/**
|
||||
* 绘制箭头
|
||||
* @param location
|
||||
* @param markerType
|
||||
* @param type
|
||||
* @param rotate
|
||||
*/
|
||||
void drawerArrowsMarkerWithLocation(MogoLatLng location, String markerType, int type, int rotate);
|
||||
|
||||
/**
|
||||
* 更新OBU/V2X传来的 单个物体感知数据
|
||||
* @param trafficData
|
||||
*/
|
||||
void updateITrafficInfo(TrafficData trafficData);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*/
|
||||
void updateITrafficLocationInfo(TrafficData trafficData);
|
||||
|
||||
/**
|
||||
* 更新识别数据颜色
|
||||
*/
|
||||
void updateITrafficThreatLevelInfo(TrafficData trafficData);
|
||||
|
||||
/**
|
||||
* 移除OBU/V2X传来的 单个物体感知数据
|
||||
* @param uuid
|
||||
*/
|
||||
void removeCvxRvInfoIndInfo(String uuid);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,12 +4,10 @@ import android.content.Context
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.map.IMogoMapService
|
||||
import com.mogo.eagle.core.function.api.map.marker.IMogoMarkerService
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.map.hdcache.IHdCacheListener
|
||||
import com.mogo.map.location.IMogoGDLocationClient
|
||||
import com.mogo.map.marker.IMogoMarkerManager
|
||||
import com.mogo.map.overlay.IMogoOverlayManager
|
||||
import com.mogo.map.overlay.*
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController
|
||||
|
||||
object CallerMapUIServiceManager {
|
||||
@@ -24,14 +22,6 @@ object CallerMapUIServiceManager {
|
||||
return serviceProvider?.mapUIController
|
||||
}
|
||||
|
||||
fun getMarkerManager(context: Context): IMogoMarkerManager? {
|
||||
return serviceProvider?.getMarkerManager(context)
|
||||
}
|
||||
|
||||
fun getMarkerService(): IMogoMarkerService? {
|
||||
return serviceProvider?.markerService
|
||||
}
|
||||
|
||||
fun cacheHDDataByCity(listener: IHdCacheListener) {
|
||||
serviceProvider?.mapUIController?.cacheHDDataByCity(listener)
|
||||
}
|
||||
@@ -44,7 +34,7 @@ object CallerMapUIServiceManager {
|
||||
return serviceProvider?.mapUIController?.isCityDataCached ?: false
|
||||
}
|
||||
|
||||
fun getOverlayManager(): IMogoOverlayManager?{
|
||||
fun getOverlayManager(): IMoGoOverlayManager? {
|
||||
return serviceProvider?.overlayManager
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.center.CenterLine;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
|
||||
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
|
||||
import com.mogo.map.road.RoadNameInfo;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
@@ -37,19 +33,9 @@ public interface IMogoMap {
|
||||
*/
|
||||
IMogoMapUIController getUIController();
|
||||
|
||||
/**
|
||||
* 在地图上添一个图片标记(marker)对象。
|
||||
*
|
||||
* @param tag 标识服务
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker addMarker(String tag, MogoMarkerOptions options);
|
||||
IMapPointOverlay addPoint(Point.Options options);
|
||||
|
||||
/**
|
||||
* 清除所有marker
|
||||
*/
|
||||
void clearAllMarkers();
|
||||
IMapPolylineOverlay addLine(Polyline.Options options);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
@@ -80,16 +66,6 @@ public interface IMogoMap {
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 在地图上添一组图片标记(marker)对象,并设置是否改变地图状态以至于所有的marker对象都在当前地图可视区域范围内显示。
|
||||
*
|
||||
* @param tag 标识服务
|
||||
* @param options
|
||||
* @param moveToCenter
|
||||
* @return
|
||||
*/
|
||||
ArrayList<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter);
|
||||
|
||||
/**
|
||||
* 从地图上删除所有的overlay(marker,circle,polyline 等对象)。
|
||||
*/
|
||||
@@ -136,14 +112,6 @@ public interface IMogoMap {
|
||||
*/
|
||||
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
|
||||
|
||||
/**
|
||||
* 添加线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline(MogoPolylineOptions options);
|
||||
|
||||
/**
|
||||
* 获取行驶方向一定长度的中心线
|
||||
*
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mogo.map.identity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 地图 marker 管理
|
||||
*/
|
||||
public interface IMogoIdentifyManager {
|
||||
|
||||
|
||||
/**
|
||||
* 要移除的感知数据uuid
|
||||
*
|
||||
* @param uuidString
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 添加感知使用到的3d模型
|
||||
*
|
||||
* @param type
|
||||
* @param modelRes
|
||||
*/
|
||||
String addPreVehicleModel(int type, int modelRes);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 自定义 infowindow 适配器
|
||||
*/
|
||||
public interface IMogoInfoWindowAdapter {
|
||||
|
||||
/**
|
||||
* 获取infowindow的布局
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
View getInfoWindow( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 地图 marker 抽象
|
||||
*/
|
||||
public interface IMogoMarker {
|
||||
|
||||
/**
|
||||
* 删除当前marker并销毁Marker的图片等资源
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* 删除当前marker。
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*
|
||||
* @param alpha
|
||||
*/
|
||||
void setAlpha( float alpha );
|
||||
|
||||
/**
|
||||
* 设置 Marker覆盖物的图标
|
||||
*
|
||||
* @param bitmap
|
||||
*/
|
||||
void setIcon( Bitmap bitmap );
|
||||
|
||||
/**
|
||||
* 设置 Marker 的图标集合,相同图案的 icon 的 marker 最好使用同一个 BitmapDescriptor 对象以节省内存空间。
|
||||
*
|
||||
* @param icons
|
||||
*/
|
||||
void setIcons( ArrayList< Bitmap > icons );
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的属性选项类 通过markerOption 给marker设置属性
|
||||
*
|
||||
* @param opt
|
||||
*/
|
||||
void setMarkerOptions( MogoMarkerOptions opt );
|
||||
|
||||
/**
|
||||
* 可以存储业务相关的数据
|
||||
*
|
||||
* @param object
|
||||
*/
|
||||
void setObject( Object object );
|
||||
|
||||
/**
|
||||
* @return 用户设置的 object 对象
|
||||
*/
|
||||
Object getObject();
|
||||
|
||||
/**
|
||||
* 设置位置
|
||||
*
|
||||
* @param lat
|
||||
* @param lng
|
||||
*/
|
||||
void setPosition( double lat, double lng );
|
||||
|
||||
/**
|
||||
* 获取坐标点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getPosition();
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物图片旋转的角度,从正北开始,逆时针计算。
|
||||
*
|
||||
* @param rotate
|
||||
*/
|
||||
void setRotateAngle( float rotate );
|
||||
|
||||
/**
|
||||
* 设置Marker 覆盖物的标题。
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
void setTitle( String title );
|
||||
|
||||
/**
|
||||
* 设置当前marker在最上面。
|
||||
*/
|
||||
void setToTop();
|
||||
|
||||
/**
|
||||
* 设置 Marker 覆盖物的可见属性。
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
void setVisible( boolean visible );
|
||||
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void setOnMarkerClickListener( IMogoMarkerClickListener listener );
|
||||
|
||||
/**
|
||||
* 获取点击事件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerClickListener getOnMarkerClickListener();
|
||||
|
||||
/**
|
||||
* 自定义 infowindow 样式接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
||||
|
||||
/**
|
||||
* 是否被销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 设置marker的归属模块
|
||||
*
|
||||
* @param mOwner
|
||||
*/
|
||||
void setOwner( String mOwner );
|
||||
|
||||
/**
|
||||
* 获取marker的归属模块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getOwner();
|
||||
|
||||
/**
|
||||
* Marker 配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoMarkerOptions getMogoMarkerOptions();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 缩放动画
|
||||
*
|
||||
* @param fromX
|
||||
* @param toX
|
||||
* @param fromY
|
||||
* @param toY
|
||||
* @param duration
|
||||
* @param interpolator
|
||||
* @param listener
|
||||
*/
|
||||
void startScaleAnimation( float fromX,
|
||||
float toX,
|
||||
float fromY,
|
||||
float toY,
|
||||
int duration,
|
||||
Interpolator interpolator,
|
||||
OnMarkerAnimationListener listener );
|
||||
|
||||
/**
|
||||
* 是否是否可点击
|
||||
*
|
||||
* @param clickable
|
||||
*/
|
||||
void setClickable( boolean clickable );
|
||||
|
||||
|
||||
/**
|
||||
* 设置是否是gps
|
||||
*
|
||||
* @param isGps
|
||||
*/
|
||||
void setGps( boolean isGps );
|
||||
|
||||
/**
|
||||
* 设置3D车模颜色
|
||||
*
|
||||
* @param anchorColor
|
||||
*/
|
||||
default void setAnchorColor( String anchorColor ) {
|
||||
|
||||
}
|
||||
|
||||
default void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 marker 内部使用资源内容 md5
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getMarkerResName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* marker 点击事件
|
||||
*/
|
||||
public interface IMogoMarkerClickListener {
|
||||
|
||||
/**
|
||||
* 事件是否继续往下传递
|
||||
*
|
||||
* @param marker
|
||||
* @return true - 事件已经处理完毕不继续往下传,否则继续往下传
|
||||
*/
|
||||
default boolean onMarkerClicked(IMogoMarker marker){
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 地图上静态Marker点击事件传递
|
||||
* @param marker
|
||||
* @return true - 事件已经处理完毕不继续往下传,否则继续往下传
|
||||
*/
|
||||
default boolean onStaticMarkerClicked(IMogoMarker marker){
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoMarkerClickListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册marker回调,各业务模块不用关注
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerMarkerClickListener(String tag, IMogoMarkerClickListener listener );
|
||||
|
||||
|
||||
/**
|
||||
* 注销marker回调,各业务模块不需要关注
|
||||
*/
|
||||
void unregisterMarkerClickListener(String tag);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-29
|
||||
* <p>
|
||||
* 动态变换 marker 样式接口
|
||||
*/
|
||||
public interface IMogoMarkerIconViewCreator {
|
||||
|
||||
/**
|
||||
* 返回自定义marker样式
|
||||
*
|
||||
* @param marker marker 的数据
|
||||
* @return
|
||||
*/
|
||||
View createView( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 地图 marker 管理
|
||||
*/
|
||||
public interface IMogoMarkerManager {
|
||||
|
||||
/**
|
||||
* 添加marker
|
||||
*
|
||||
* @param tag 标识调用者
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker addMarker(String tag, MogoMarkerOptions options);
|
||||
|
||||
/**
|
||||
* 添加多个marker
|
||||
*
|
||||
* @param tag 标识调用者
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
List<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter);
|
||||
|
||||
/**
|
||||
* 清除所有marker
|
||||
*/
|
||||
void clearAllMarker();
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 添加感知使用到的3d模型
|
||||
*
|
||||
* @param type
|
||||
* @param modelRes
|
||||
*/
|
||||
String addPreVehicleModel(int type, int modelRes);
|
||||
|
||||
/**
|
||||
* 要移除的感知数据uuid
|
||||
*
|
||||
* @param uuidString
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 移除某一个类型、某个模块的 markers
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
void removeMarkers(String tag);
|
||||
|
||||
/**
|
||||
* 移除地图上添加的所有markers
|
||||
*/
|
||||
void removeMarkers();
|
||||
|
||||
/**
|
||||
* 显示地图上添加的所有markers
|
||||
*/
|
||||
void visibleAllMarkers();
|
||||
|
||||
/**
|
||||
* 隐藏地图上添加的所有markers
|
||||
*/
|
||||
void inVisibleAllMarkers();
|
||||
|
||||
/**
|
||||
* 隐藏除了某些类别的所有marker {@link MogoMarkerOptions Owner}
|
||||
*
|
||||
* @param owner
|
||||
*/
|
||||
void inVisibleWithoutMarkers(String... owner); //todo 后续需要把Owner类别统一起来,基类下沉,此接口为临时方案,应该设计为隐藏某一类元素
|
||||
|
||||
/**
|
||||
* 获取某种类型的全部marker。
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @return
|
||||
*/
|
||||
List<IMogoMarker> getMarkers(String tag);
|
||||
|
||||
/**
|
||||
* 获取所有类型的marker。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<IMogoMarker>> getAllMarkers();
|
||||
|
||||
/**
|
||||
* 仅保留指定类型的tag
|
||||
*
|
||||
* @param tag 需要保留的类型
|
||||
*/
|
||||
void removeMarkersExcept(String tag);
|
||||
|
||||
/**
|
||||
* 添加搜索路线
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param startPoint 起点
|
||||
* @param endPoint 终点
|
||||
* @param wayPoints 途经点
|
||||
*/
|
||||
void addRouteWay(Context context, MogoLatLng startPoint, MogoLatLng endPoint, List<MogoLatLng> wayPoints);
|
||||
|
||||
/**
|
||||
* 移除添加的导航预测路线
|
||||
*/
|
||||
void removeRouteWayOverlay();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
public class MarkerType {
|
||||
|
||||
public static final String MAP_STATIC = "mapStatic";
|
||||
public static final String MAP_STATIC_TRAFFIC = "trafficcamera";
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.location.Location;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.RawRes;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 地图marker
|
||||
*/
|
||||
public class MogoMarkerOptions extends Observable {
|
||||
|
||||
// marker 唯一标记
|
||||
private String uuid;
|
||||
private int markerType;
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
// 设置 Marker覆盖物 的标题
|
||||
private String title;
|
||||
// 设置 Marker覆盖物的 文字描述
|
||||
private String snippet;
|
||||
// 设置Marker覆盖物的图标。
|
||||
private Bitmap icon;
|
||||
// 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果。
|
||||
private ArrayList< Bitmap > icons;
|
||||
// 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快。
|
||||
private int period = 20;
|
||||
// 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算。
|
||||
private float rotate;
|
||||
// 设置Marker覆盖物是否平贴地图。
|
||||
private boolean flat = false;
|
||||
// 设置Marker覆盖物是否可见。
|
||||
private boolean visible = true;
|
||||
// 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
private boolean inifoWindowEnable = true;
|
||||
// 设置Marker覆盖物的透明度
|
||||
private float alpha = 1.0f;
|
||||
|
||||
// 设置Marker覆盖物的缩放
|
||||
private float scale = 1.0f;
|
||||
|
||||
// Marker覆盖物的坐标是否是Gps
|
||||
private boolean isGps = false;
|
||||
|
||||
// Marker覆盖物锚点在水平范围的比例。
|
||||
private float u = 0.5f;
|
||||
// Marker覆盖物锚点垂直范围的比例。
|
||||
private float v = 1f;
|
||||
|
||||
// 设置Marker覆盖物是否可拖拽。
|
||||
private boolean draggable = false;
|
||||
|
||||
// Marker覆盖物的InfoWindow相对X 轴的Marker的偏移
|
||||
private int offsetX = 0;
|
||||
// Marker覆盖物的InfoWindow相对Y 轴的Marker的偏移
|
||||
private int offsetY = 0;
|
||||
|
||||
// 设置Marker覆盖物 zIndex。
|
||||
private int zIndex = 0;
|
||||
// 自定义样式
|
||||
private View mIconView;
|
||||
// marker 归属模块
|
||||
private String mOwner;
|
||||
|
||||
private Object mObject;
|
||||
|
||||
/**
|
||||
* 是否加入marker管理
|
||||
*/
|
||||
private boolean mAutoManager = true;
|
||||
|
||||
private @RawRes
|
||||
int mIcon3DRes = 0;
|
||||
private String mAnchorColor;
|
||||
|
||||
private boolean mIs3DMode = false;
|
||||
|
||||
private boolean mIsControlAngle = false;
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
private String mResName;
|
||||
|
||||
/**
|
||||
* 吸附在车道上
|
||||
*/
|
||||
private boolean mMatchOnRoadSide = true;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getMarkerType() {
|
||||
return markerType;
|
||||
}
|
||||
|
||||
public void setMarkerType(int markerType) {
|
||||
this.markerType = markerType;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions matchOnRoadSide(boolean matchOnRoadSide ) {
|
||||
this.mMatchOnRoadSide = matchOnRoadSide;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMatchOnRoadSide() {
|
||||
return mMatchOnRoadSide;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions resName( String resName ) {
|
||||
this.mResName = resName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getResName() {
|
||||
return mResName;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions controlAngle( boolean controlAngle ) {
|
||||
this.mIsControlAngle = controlAngle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isControlAngle() {
|
||||
return mIsControlAngle;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions set3DMode( boolean is3DMode ) {
|
||||
mIs3DMode = is3DMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean is3DMode() {
|
||||
return mIs3DMode;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( MogoLatLng latLng ) {
|
||||
if ( latLng != null ) {
|
||||
latitude( latLng.lat );
|
||||
longitude( latLng.lon );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( MogoLocation location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( Location location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions latitude( double latitude ) {
|
||||
this.latitude = latitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions longitude( double longitude ) {
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions title( String title ) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions snippet( String snippet ) {
|
||||
this.snippet = snippet;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
*
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( Bitmap icon ) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions icons( ArrayList< Bitmap > icons ) {
|
||||
this.icons = icons;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions period( int period ) {
|
||||
this.period = period;
|
||||
if ( this.period < 1 ) {
|
||||
this.period = 1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions rotate( float rotate ) {
|
||||
this.rotate = rotate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions flat( boolean flat ) {
|
||||
this.flat = flat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions visible( boolean visible ) {
|
||||
this.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions inifoWindowEnable( boolean inifoWindowEnable ) {
|
||||
this.inifoWindowEnable = inifoWindowEnable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions alpha( float alpha ) {
|
||||
this.alpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions scale( float scale ) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public MogoMarkerOptions gps( boolean gps ) {
|
||||
isGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions anchor( float u, float v ) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions draggable( boolean draggable ) {
|
||||
this.draggable = draggable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions setInfoWindowOffset( int offsetX, int offsetY ) {
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions zIndex( int zIndex ) {
|
||||
this.zIndex = zIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions data(Object object ) {
|
||||
this.mObject = object;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义marker图层样式,优先使用 icon {@link #icon(Bitmap)}作为marker资源
|
||||
*
|
||||
* @param iconView
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( View iconView ) {
|
||||
this.mIconView = iconView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions owner( String owner ) {
|
||||
this.mOwner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions icon3DRes( @RawRes int icon3DRes ) {
|
||||
this.mIcon3DRes = icon3DRes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions anchorColor( String anchorColor ) {
|
||||
this.mAnchorColor = anchorColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return snippet;
|
||||
}
|
||||
|
||||
public Bitmap getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public ArrayList< Bitmap > getIcons() {
|
||||
return icons;
|
||||
}
|
||||
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public float getRotate() {
|
||||
return rotate;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public boolean isInifoWindowEnable() {
|
||||
return inifoWindowEnable;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public boolean isGps() {
|
||||
return isGps;
|
||||
}
|
||||
|
||||
public float getU() {
|
||||
return u;
|
||||
}
|
||||
|
||||
public float getV() {
|
||||
return v;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return draggable;
|
||||
}
|
||||
|
||||
public int getOffsetX() {
|
||||
return offsetX;
|
||||
}
|
||||
|
||||
public int getOffsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
public int getzIndex() {
|
||||
return zIndex;
|
||||
}
|
||||
|
||||
public View getIconView() {
|
||||
return mIconView;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
public boolean isAutoManager() {
|
||||
return mAutoManager;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions autoManager( boolean autoManager ) {
|
||||
this.mAutoManager = autoManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getIcon3DRes() {
|
||||
return mIcon3DRes;
|
||||
}
|
||||
|
||||
public String getAnchorColor() {
|
||||
return mAnchorColor;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions setGps(boolean gps) {
|
||||
isGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MogoMarkerOptions{" +
|
||||
"uuid='" + uuid + '\'' +
|
||||
", markerType=" + markerType +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", title='" + title + '\'' +
|
||||
", snippet='" + snippet + '\'' +
|
||||
", icon=" + icon +
|
||||
", icons=" + icons +
|
||||
", period=" + period +
|
||||
", rotate=" + rotate +
|
||||
", flat=" + flat +
|
||||
", visible=" + visible +
|
||||
", inifoWindowEnable=" + inifoWindowEnable +
|
||||
", alpha=" + alpha +
|
||||
", scale=" + scale +
|
||||
", isGps=" + isGps +
|
||||
", u=" + u +
|
||||
", v=" + v +
|
||||
", draggable=" + draggable +
|
||||
", offsetX=" + offsetX +
|
||||
", offsetY=" + offsetY +
|
||||
", zIndex=" + zIndex +
|
||||
", mIconView=" + mIconView +
|
||||
", mOwner='" + mOwner + '\'' +
|
||||
", mObject=" + mObject +
|
||||
", mAutoManager=" + mAutoManager +
|
||||
", mIcon3DRes=" + mIcon3DRes +
|
||||
", mAnchorColor='" + mAnchorColor + '\'' +
|
||||
", mIs3DMode=" + mIs3DMode +
|
||||
", mIsControlAngle=" + mIsControlAngle +
|
||||
", mResName='" + mResName + '\'' +
|
||||
", mMatchOnRoadSide=" + mMatchOnRoadSide +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.mogo.map.marker
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.text.TextUtils
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
*
|
||||
*
|
||||
* 管理地图上的所有marker
|
||||
*/
|
||||
class MogoMarkersHandler private constructor() : IMogoMarkerClickListener,
|
||||
IMogoMarkerClickListenerRegister {
|
||||
|
||||
companion object {
|
||||
val mogoMarkersHandler by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoMarkersHandler()
|
||||
}
|
||||
}
|
||||
|
||||
private val mMap: ConcurrentHashMap<String, IMogoMarkerClickListener> = ConcurrentHashMap()
|
||||
private val mServicesMarkers: MutableMap<String, MutableList<IMogoMarker>?> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
override fun registerMarkerClickListener(tag: String, listener: IMogoMarkerClickListener) {
|
||||
if (mMap.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMap[tag] = listener
|
||||
}
|
||||
|
||||
override fun unregisterMarkerClickListener(tag: String) {
|
||||
if (!mMap.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMap.remove(tag)
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun visibleAll() {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker -> mogoMarker.setVisible(true) })
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun inVisibleAll() {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker -> mogoMarker.setVisible(false) })
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun inVisibleMarkers(vararg owner: String?) {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker ->
|
||||
if (TextUtils.isEmpty(mogoMarker.owner)) {
|
||||
mogoMarker.setVisible(false)
|
||||
}
|
||||
if (!Arrays.asList(*owner).contains(mogoMarker.owner)) {
|
||||
mogoMarker.setVisible(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun removeAll() {
|
||||
val mogoMarkers: Collection<List<IMogoMarker>?> = mServicesMarkers.values
|
||||
for (mogoMarkerList in mogoMarkers) {
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (mogoMarker in mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mServicesMarkers.clear()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun remove(tag: String) {
|
||||
val mogoMarkerList = mServicesMarkers.remove(tag)
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (mogoMarker in mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
mogoMarkerList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun getMarkers(tag: String): List<IMogoMarker>? {
|
||||
return mServicesMarkers[tag]
|
||||
}
|
||||
|
||||
@get:Synchronized
|
||||
val allMarkers: Map<String, MutableList<IMogoMarker>?>
|
||||
get() = mServicesMarkers
|
||||
|
||||
@Synchronized
|
||||
fun add(tag: String, marker: IMogoMarker?) {
|
||||
if (marker == null) {
|
||||
return
|
||||
}
|
||||
if (mServicesMarkers[tag] == null) {
|
||||
mServicesMarkers[tag] = ArrayList()
|
||||
}
|
||||
mServicesMarkers[tag]!!.add(marker)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun add(tag: String, markers: List<IMogoMarker>?) {
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return
|
||||
}
|
||||
if (mServicesMarkers[tag] == null) {
|
||||
mServicesMarkers[tag] = ArrayList()
|
||||
}
|
||||
mServicesMarkers[tag]!!.addAll(markers)
|
||||
}
|
||||
|
||||
override fun onMarkerClicked(marker: IMogoMarker): Boolean {
|
||||
val iMogoMarker = mMap[marker.owner]
|
||||
return iMogoMarker?.onMarkerClicked(marker) ?: false
|
||||
}
|
||||
|
||||
override fun onStaticMarkerClicked(marker: IMogoMarker): Boolean {
|
||||
val iMogoMarker = mMap[marker.owner]
|
||||
return iMogoMarker?.onStaticMarkerClicked(marker) ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tag 需要保留的类型
|
||||
*/
|
||||
fun deleteAllExcept(tag: String) {
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
return
|
||||
}
|
||||
val mogoMarkerList = mServicesMarkers.remove(tag)
|
||||
for (value in mServicesMarkers.values) {
|
||||
if (value != null && value.isNotEmpty()) {
|
||||
for (mogoMarker in value) {
|
||||
mogoMarker.destroy()
|
||||
}
|
||||
value.clear()
|
||||
}
|
||||
}
|
||||
mServicesMarkers[tag] = mogoMarkerList
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mogo.map.marker.anim;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-22
|
||||
* <p>
|
||||
* marker 动画监听
|
||||
*/
|
||||
public interface OnMarkerAnimationListener {
|
||||
|
||||
default void onAnimStart() {
|
||||
}
|
||||
|
||||
default void onAnimEnd() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mogo.map.overlay
|
||||
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import com.mogo.map.overlay.point.Point.Options as PointOptions
|
||||
import com.mogo.map.overlay.line.Polyline.Options as LineOptions
|
||||
|
||||
interface IMoGoOverlayManager {
|
||||
|
||||
fun showOrUpdatePoint(options: PointOptions): Point?
|
||||
|
||||
fun hidePoint(id: String)
|
||||
|
||||
fun hidePoint(p: Point)
|
||||
|
||||
fun hideAllPointsInOwner(owner: String)
|
||||
|
||||
fun hideAllPointsInLevel(level: Level)
|
||||
|
||||
fun hideAllPoints()
|
||||
|
||||
fun removePoint(id: String)
|
||||
|
||||
fun removePoint(p: Point)
|
||||
|
||||
fun removeAllPointsInOwner(owner: String)
|
||||
|
||||
fun removeAllPointsInLevel(level: Level)
|
||||
|
||||
fun removeAllPoints()
|
||||
|
||||
fun showAllPoints()
|
||||
|
||||
fun showAllPointsInOwner(owner: String)
|
||||
|
||||
fun showAllPointsInLevel(level: Level)
|
||||
|
||||
fun showPoint(id: String)
|
||||
|
||||
fun showOrUpdateLine(options: LineOptions): Polyline?
|
||||
|
||||
fun hideLine(id: String)
|
||||
|
||||
fun hideLine(p: Polyline)
|
||||
|
||||
fun hideAllLinesInOwner(owner: String)
|
||||
|
||||
fun hideAllLinesInLevel(level: Level)
|
||||
|
||||
fun hideAllLines()
|
||||
|
||||
fun removeLine(id: String)
|
||||
|
||||
fun removeLine(p: Polyline)
|
||||
|
||||
fun removeAllLinesInOwner(owner: String)
|
||||
|
||||
fun removeAllLinesInLevel(level: Level)
|
||||
|
||||
fun removeAllLines()
|
||||
|
||||
fun showAllLines()
|
||||
|
||||
fun showAllLinesInOwner(owner: String)
|
||||
|
||||
fun showAllLinesInLevel(level: Level)
|
||||
|
||||
fun showLine(id: String)
|
||||
|
||||
fun hideAllPointsExceptIds(vararg ids: String)
|
||||
|
||||
fun hideAllPointsExceptOwners(vararg owners: String)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 覆盖物
|
||||
*/
|
||||
public interface IMogoOverlayManager {
|
||||
|
||||
/**
|
||||
* 绘制线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline( MogoPolylineOptions options );
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.map.IDestroyable;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段
|
||||
*/
|
||||
public interface IMogoPolyline extends IDestroyable {
|
||||
|
||||
|
||||
/**
|
||||
* 是否已经销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 移除
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* 获取ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* 设置绘制点数据
|
||||
*
|
||||
* @param lonLats
|
||||
*/
|
||||
void setPoints( List< MogoLatLng > lonLats );
|
||||
|
||||
/**
|
||||
* 获取点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List< MogoLatLng > getPoints();
|
||||
|
||||
/**
|
||||
* 测地线
|
||||
*
|
||||
* @param draw
|
||||
*/
|
||||
void setGeodesic( boolean draw );
|
||||
|
||||
/**
|
||||
* 是否设置了测地线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isGeodesic();
|
||||
|
||||
/**
|
||||
* 虚线
|
||||
*
|
||||
* @param dottedLine
|
||||
*/
|
||||
void setDottedLine( boolean dottedLine );
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDottedLine();
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*
|
||||
* @param width
|
||||
*/
|
||||
void setWidth( float width );
|
||||
|
||||
/**
|
||||
* 获取线宽
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getWidth();
|
||||
|
||||
/**
|
||||
* 设置线条颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
void setColor( @ColorInt int color );
|
||||
|
||||
/**
|
||||
* 获取线条颜色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ColorInt
|
||||
int getColor();
|
||||
|
||||
/**
|
||||
* 设置Z轴
|
||||
*/
|
||||
void setZIndex( float zIndex );
|
||||
|
||||
/**
|
||||
* 获取Z轴
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getZIndex();
|
||||
|
||||
/**
|
||||
* 设置显示/隐藏
|
||||
*/
|
||||
void setVisible( boolean visible );
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
*/
|
||||
void setTransparency( float transparency );
|
||||
|
||||
/**
|
||||
* 设置配置项
|
||||
*/
|
||||
void setOption( MogoPolylineOptions option );
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段属性
|
||||
*/
|
||||
public class MogoPolylineOptions {
|
||||
|
||||
public boolean useFacade = false;
|
||||
public float maxIndex = Float.MIN_VALUE;
|
||||
private List<MogoLatLng> mPoints;
|
||||
private float mWidth = 10.0F;
|
||||
private int mColor = Color.BLACK;
|
||||
private float mZIndex = 0.0F;
|
||||
private boolean mIsVisible = true;
|
||||
private boolean mIsGeodesic = false;
|
||||
private boolean mIsDottedLine = false;
|
||||
private boolean mIsGradient = false;
|
||||
private float mTransparency = 1.0F;
|
||||
private boolean mIsAboveMaskLayer = false;
|
||||
private boolean mIsPointsUpdated = false;
|
||||
private boolean mGps = false;
|
||||
private List<Integer> mColorValues;
|
||||
|
||||
private float brightSpeed = Float.MIN_VALUE;
|
||||
|
||||
private int brightColor = -1;
|
||||
|
||||
private boolean isBrightOn = false;
|
||||
|
||||
public MogoPolylineOptions() {
|
||||
this.mPoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶点
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions points(List<MogoLatLng> points) {
|
||||
this.mPoints.clear();
|
||||
this.mPoints.addAll(points);
|
||||
this.mIsPointsUpdated = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加顶点到集合最后
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions add(MogoLatLng... points) {
|
||||
if (points != null) {
|
||||
this.mPoints.addAll(Arrays.asList(points));
|
||||
this.mIsPointsUpdated = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add(double lon, double lat) {
|
||||
this.mPoints.add(new MogoLatLng(lat, lon));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add(MogoLocation location) {
|
||||
if (location != null) {
|
||||
this.mPoints.add(new MogoLatLng(location.getLatitude(), location.getLongitude()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*/
|
||||
public MogoPolylineOptions width(float width) {
|
||||
this.mWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线的颜色
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions color(@ColorInt int color) {
|
||||
this.mColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Z轴的值
|
||||
*
|
||||
* @param zIndex
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions zIndex(float zIndex) {
|
||||
this.mZIndex = zIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否可见
|
||||
*
|
||||
* @param isVisible
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions visible(boolean isVisible) {
|
||||
this.mIsVisible = isVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否绘制测地线
|
||||
*
|
||||
* @param isGeodesic
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions geodesic(boolean isGeodesic) {
|
||||
this.mIsGeodesic = isGeodesic;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @param isDottedLine
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions dottedLine(boolean isDottedLine) {
|
||||
this.mIsDottedLine = isDottedLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否使用渐变色
|
||||
*
|
||||
* @param isGradient
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions useGradient(boolean isGradient) {
|
||||
this.mIsGradient = isGradient;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions maxIndex(float maxIndex) {
|
||||
this.maxIndex = maxIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions transparency(float transparency) {
|
||||
this.mTransparency = transparency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions brightSpeed(float speed) {
|
||||
this.brightSpeed = speed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions openBright(boolean on) {
|
||||
this.isBrightOn = on;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions brightColor(int color) {
|
||||
this.brightColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions useFacade(boolean useFacade) {
|
||||
this.useFacade = useFacade;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param isAboveMaskLayer
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions aboveMaskLayer(boolean isAboveMaskLayer) {
|
||||
this.mIsAboveMaskLayer = isAboveMaskLayer;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions colorValues(List<Integer> colors) {
|
||||
mColorValues = colors;
|
||||
return this;
|
||||
}
|
||||
public boolean gps() {
|
||||
return mGps;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions setGps(boolean gps) {
|
||||
mGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<MogoLatLng> getPoints() {
|
||||
return mPoints;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public float getZIndex() {
|
||||
return mZIndex;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mIsVisible;
|
||||
}
|
||||
|
||||
public boolean isGeodesic() {
|
||||
return mIsGeodesic;
|
||||
}
|
||||
|
||||
public boolean isDottedLine() {
|
||||
return mIsDottedLine;
|
||||
}
|
||||
|
||||
public boolean isGradient() {
|
||||
return mIsGradient;
|
||||
}
|
||||
|
||||
public boolean useFacade() {
|
||||
return useFacade;
|
||||
}
|
||||
|
||||
|
||||
public float getTransparency() {
|
||||
return mTransparency;
|
||||
}
|
||||
|
||||
public boolean isAboveMaskLayer() {
|
||||
return mIsAboveMaskLayer;
|
||||
}
|
||||
|
||||
public boolean isPointsUpdated() {
|
||||
return mIsPointsUpdated;
|
||||
}
|
||||
|
||||
public float getBrightSpeed() {
|
||||
return brightSpeed;
|
||||
}
|
||||
|
||||
public boolean isBrightOn() {
|
||||
return isBrightOn;
|
||||
}
|
||||
|
||||
public int getBrightColor() {
|
||||
return brightColor;
|
||||
}
|
||||
|
||||
public List<Integer> getColorValues() {
|
||||
return mColorValues;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.map.overlay.core
|
||||
|
||||
enum class Level(val zIndex: Int) {
|
||||
|
||||
|
||||
DEFAULT(10),
|
||||
|
||||
/**
|
||||
* 地图上Marker覆盖物
|
||||
*/
|
||||
MAP_MARKER(100),
|
||||
|
||||
/**
|
||||
* 车道中心线
|
||||
*/
|
||||
ROAD_CENTER_LINE(40000),
|
||||
|
||||
/**
|
||||
* 前车引导线
|
||||
*/
|
||||
GUIDE_ROUTE_LINE(75000),
|
||||
|
||||
|
||||
/**
|
||||
* 道路围栏区域绘制
|
||||
*/
|
||||
MAP_POLYGON(76000)
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.mogo.map.overlay.line
|
||||
|
||||
import android.graphics.*
|
||||
import android.text.TextUtils
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import java.util.UUID
|
||||
|
||||
data class Polyline(val id: String, val owner: String, val level: Level, val options: Options) {
|
||||
|
||||
@Volatile
|
||||
var delegate: IMapPolylineOverlay? = null
|
||||
|
||||
class Options private constructor(private val builder: Builder) {
|
||||
|
||||
val id: String = builder.id ?: throw AssertionError("id must not be null.")
|
||||
|
||||
val owner: String = builder.owner
|
||||
|
||||
val level: Level = builder.level
|
||||
|
||||
val useFacade: Boolean = builder.useFacade
|
||||
|
||||
val maxIndex: Float = builder.maxIndex
|
||||
|
||||
val points: List<MogoLatLng>? = builder.points
|
||||
|
||||
val width = builder.width
|
||||
|
||||
val color: Int = builder.color
|
||||
|
||||
val isVisible = builder.isVisible
|
||||
|
||||
val isGeodesic = builder.isGeodesic
|
||||
|
||||
val isDottedLine = builder.isDottedLine
|
||||
|
||||
val dottedLineType = builder.dottedLineType
|
||||
|
||||
val isGradient = builder.isGradient
|
||||
|
||||
val alpha = builder.alpha
|
||||
|
||||
val isUseGps = builder.isUseGps
|
||||
|
||||
val colors: List<Int>? = builder.colors
|
||||
|
||||
val isLightOn: Boolean = builder.isLightOn
|
||||
|
||||
val lightColor: Int = builder.lightColor
|
||||
|
||||
val lightSpeed: Float = builder.lightSpeed
|
||||
|
||||
fun builder(): Builder {
|
||||
return builder
|
||||
}
|
||||
|
||||
class Builder(val owner: String, val level: Level) {
|
||||
|
||||
internal var id: String? = null
|
||||
|
||||
internal var useFacade: Boolean = false
|
||||
|
||||
internal var maxIndex: Float = Float.MIN_VALUE
|
||||
|
||||
internal var points: List<MogoLatLng>? = null
|
||||
|
||||
internal var width = 10.0f
|
||||
|
||||
internal var color: Int = Color.BLACK
|
||||
|
||||
internal var isVisible = true
|
||||
|
||||
internal var isGeodesic = false
|
||||
|
||||
internal var isDottedLine = false
|
||||
|
||||
internal var dottedLineType = -1
|
||||
|
||||
internal var isGradient = false
|
||||
|
||||
internal var alpha = 1.0f
|
||||
|
||||
internal var isUseGps = false
|
||||
|
||||
internal var colors: List<Int>? = null
|
||||
|
||||
internal var isLightOn: Boolean = false
|
||||
|
||||
internal var lightColor: Int = Color.WHITE
|
||||
|
||||
internal var lightSpeed: Float = 0f
|
||||
|
||||
fun setId(id: String) = apply {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun points(points: List<MogoLatLng>) = apply {
|
||||
this.points = points
|
||||
}
|
||||
|
||||
fun colors(colors: List<Int>) = apply {
|
||||
this.colors = colors
|
||||
}
|
||||
|
||||
fun color(color: Int) = apply {
|
||||
this.color = color
|
||||
}
|
||||
|
||||
fun setVisible(visible: Boolean) = apply {
|
||||
this.isVisible = visible
|
||||
}
|
||||
|
||||
fun setWidth(width: Float) = apply {
|
||||
this.width = width
|
||||
}
|
||||
|
||||
fun setMaxIndex(maxIndex: Float) = apply {
|
||||
this.maxIndex = maxIndex
|
||||
}
|
||||
|
||||
fun useFacade(facade: Boolean) = apply {
|
||||
this.useFacade = facade
|
||||
}
|
||||
|
||||
fun setGeodesic(isGeodesic: Boolean) = apply {
|
||||
this.isGeodesic = isGeodesic
|
||||
}
|
||||
|
||||
fun setIsDottedLine(isDottedLine: Boolean) = apply {
|
||||
this.isDottedLine = isDottedLine
|
||||
}
|
||||
|
||||
fun setDottedLineType(type: Int) = apply {
|
||||
this.dottedLineType = type
|
||||
}
|
||||
|
||||
fun setIsGradient(isGradient: Boolean) = apply {
|
||||
this.isGradient = isGradient
|
||||
}
|
||||
|
||||
fun setAlpha(alpha: Float) = apply {
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
fun setUseGps(isUseGps: Boolean) = apply {
|
||||
this.isUseGps = isUseGps
|
||||
}
|
||||
|
||||
fun setLightOn(isLightOn: Boolean) = apply {
|
||||
this.isLightOn = isLightOn
|
||||
}
|
||||
|
||||
fun setLightColor(color: Int) = apply {
|
||||
this.lightColor = color
|
||||
}
|
||||
|
||||
fun setLightSpeed(speed: Float) = apply {
|
||||
this.lightSpeed = speed
|
||||
}
|
||||
|
||||
fun build(): Options {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw AssertionError("id must not be null.")
|
||||
}
|
||||
return Options(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Polyline
|
||||
|
||||
if (id != other.id) return false
|
||||
if (owner != other.owner) return false
|
||||
if (level != other.level) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + owner.hashCode()
|
||||
result = 31 * result + level.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.mogo.map.overlay.point
|
||||
|
||||
import android.graphics.*
|
||||
import android.text.TextUtils
|
||||
import android.view.*
|
||||
import androidx.annotation.*
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import java.util.*
|
||||
|
||||
data class Point(val id: String, val owner: String, val level: Level, val option: Options) {
|
||||
|
||||
@Volatile
|
||||
var delegate: IMapPointOverlay? = null
|
||||
|
||||
/**
|
||||
*
|
||||
* 地图上绘制点相关的参数
|
||||
*/
|
||||
class Options private constructor(private val builder: Builder){
|
||||
|
||||
/**
|
||||
* 唯一标识,可以通过此标识,操作对点的显示和隐藏
|
||||
*/
|
||||
val id: String = builder.id ?: throw AssertionError("id must not be null")
|
||||
|
||||
/**
|
||||
* 当前地图覆盖物所在level(zIndex值在此存储)
|
||||
*/
|
||||
val level: Level = builder.level
|
||||
|
||||
/**
|
||||
* 当前地图覆盖物所属的业务类型
|
||||
*/
|
||||
val owner: String = builder.owner
|
||||
|
||||
/**
|
||||
* 绘制点的纬度
|
||||
*/
|
||||
val latitude: Double = builder.latitude ?: 0.0
|
||||
|
||||
/**
|
||||
* 绘制点的经度
|
||||
*/
|
||||
val longitude: Double = builder.longitude ?: 0.0
|
||||
|
||||
/**
|
||||
* 3D模型
|
||||
*/
|
||||
@RawRes
|
||||
val icon3DRes: Int = builder.icon3DRes
|
||||
|
||||
/**
|
||||
* 自定义样式
|
||||
*/
|
||||
val iconView: View? = builder.iconView
|
||||
|
||||
/**
|
||||
* 指定覆盖物的颜色
|
||||
*/
|
||||
val anchorColor: String? = builder.anchorColor
|
||||
|
||||
/**
|
||||
* 文字标题
|
||||
*/
|
||||
val title: String? = builder.title
|
||||
|
||||
/**
|
||||
* 文字描述
|
||||
*/
|
||||
val snippet: String? = builder.snippet
|
||||
|
||||
/**
|
||||
* 图标对应的Bitmap对象
|
||||
*/
|
||||
val icon: Bitmap? = builder.icon
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果
|
||||
*/
|
||||
val icons: ArrayList<Bitmap>? = builder.icons
|
||||
|
||||
/**
|
||||
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快
|
||||
*/
|
||||
val period = builder.period
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算
|
||||
*/
|
||||
val rotate = builder.rotate
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否平贴地图
|
||||
*/
|
||||
val isFlat = builder.isFlat
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否可见
|
||||
*/
|
||||
val isVisible = builder.isVisible
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
*/
|
||||
val isInfoWindowEnable = builder.isInfoWindowEnable
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
val alpha = builder.alpha
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
val scale = builder.scale
|
||||
|
||||
/**
|
||||
* Marker覆盖物的坐标是否是Gps
|
||||
*/
|
||||
val isGps = builder.isGps
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点在水平范围的比例
|
||||
*/
|
||||
val u = builder.u
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点垂直范围的比例
|
||||
*/
|
||||
val v = builder.v
|
||||
|
||||
/**
|
||||
* 是否是3D模型
|
||||
*/
|
||||
val is3DMode: Boolean = builder.is3DMode
|
||||
|
||||
/**
|
||||
* 是否控制角度
|
||||
*/
|
||||
val isControlAngle = builder.isControlAngle
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
val resName: String? = builder.resName
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
val moveToCenter: Boolean = builder.moveToCenter
|
||||
|
||||
fun builder(): Builder {
|
||||
return builder
|
||||
}
|
||||
|
||||
class Builder(val owner: String,val level: Level){
|
||||
|
||||
/**
|
||||
* 唯一标识,可以通过此标识,操作对点的显示和隐藏
|
||||
*/
|
||||
internal var id: String? = null
|
||||
|
||||
/**
|
||||
* 绘制点的纬度
|
||||
*/
|
||||
internal var latitude: Double? = null
|
||||
|
||||
/**
|
||||
* 绘制点的经度
|
||||
*/
|
||||
internal var longitude: Double? = null
|
||||
|
||||
/**
|
||||
* 3D模型
|
||||
*/
|
||||
@RawRes
|
||||
internal var icon3DRes = 0
|
||||
|
||||
|
||||
/**
|
||||
* 自定义样式
|
||||
*/
|
||||
internal var iconView: View? = null
|
||||
|
||||
/**
|
||||
* 指定覆盖物的颜色
|
||||
*/
|
||||
internal var anchorColor: String? = null
|
||||
|
||||
/**
|
||||
* 文字标题
|
||||
*/
|
||||
internal var title: String? = null
|
||||
|
||||
/**
|
||||
* 文字描述
|
||||
*/
|
||||
internal var snippet: String? = null
|
||||
|
||||
/**
|
||||
* 图标对应的Bitmap对象
|
||||
*/
|
||||
internal var icon: Bitmap? = null
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果
|
||||
*/
|
||||
internal var icons: ArrayList<Bitmap>? = null
|
||||
|
||||
/**
|
||||
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快
|
||||
*/
|
||||
internal var period = 0
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算
|
||||
*/
|
||||
internal var rotate = 0f
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否平贴地图
|
||||
*/
|
||||
internal var isFlat = false
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否可见
|
||||
*/
|
||||
internal var isVisible = true
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
*/
|
||||
internal var isInfoWindowEnable = true
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
internal var alpha = 1.0f
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
internal var scale = 1.0f
|
||||
|
||||
/**
|
||||
* Marker覆盖物的坐标是否是Gps
|
||||
*/
|
||||
internal var isGps = false
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点在水平范围的比例
|
||||
*/
|
||||
internal var u = 0.5f
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点垂直范围的比例
|
||||
*/
|
||||
internal var v = 0.5f
|
||||
|
||||
|
||||
/**
|
||||
* 是否是3D模型
|
||||
*/
|
||||
internal var is3DMode: Boolean = false
|
||||
|
||||
/**
|
||||
* 是否控制角度
|
||||
*/
|
||||
internal var isControlAngle = false
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
internal var resName: String? = null
|
||||
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
internal var moveToCenter: Boolean = true
|
||||
|
||||
fun setId(id: String) = apply {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun resName(resName: String?) = apply {
|
||||
this.resName = resName
|
||||
}
|
||||
|
||||
fun controlAngle(controlAngle: Boolean) = apply {
|
||||
isControlAngle = controlAngle
|
||||
}
|
||||
|
||||
fun set3DMode(is3DMode: Boolean) = apply {
|
||||
this.is3DMode = is3DMode
|
||||
}
|
||||
|
||||
fun latitude(latitude: Double) = apply {
|
||||
this.latitude = latitude
|
||||
}
|
||||
|
||||
fun longitude(longitude: Double) = apply {
|
||||
this.longitude = longitude
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
fun icon(icon: Bitmap?) = apply {
|
||||
this.icon = icon
|
||||
}
|
||||
|
||||
/**
|
||||
* 帧动画对应的图片序列
|
||||
*/
|
||||
fun icons(icons: ArrayList<Bitmap>?) = apply {
|
||||
this.icons = icons
|
||||
}
|
||||
|
||||
/**
|
||||
* 帧动画执行完成一次需要的时长,时间越短,帧动画越快
|
||||
*/
|
||||
fun period(period: Int) = apply {
|
||||
this.period = period
|
||||
if (this.period < 1) {
|
||||
this.period = 1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* marker对应的资源的,旋转角度,正北方为0度,逆时针计算
|
||||
*/
|
||||
fun rotate(rotate: Float) = apply {
|
||||
this.rotate = rotate
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否平铺在地图上
|
||||
*/
|
||||
fun flat(flat: Boolean) = apply {
|
||||
isFlat = flat
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
fun visible(visible: Boolean) = apply {
|
||||
isVisible = visible
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的透明度
|
||||
*/
|
||||
fun alpha(alpha: Float) = apply {
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的缩放比例
|
||||
*/
|
||||
fun scale(scale: Float) = apply {
|
||||
this.scale = scale
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否使用GPS坐标
|
||||
*/
|
||||
fun isUseGps(gps: Boolean) = apply {
|
||||
this.isGps = gps
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物锚点在水平和垂直方向的比例
|
||||
*/
|
||||
fun anchor(u: Float, v: Float) = apply {
|
||||
this.u = u
|
||||
this.v = v
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义marker图层样式,优先使用 icon [.icon]作为marker资源
|
||||
*
|
||||
* @param iconView
|
||||
* @return
|
||||
*/
|
||||
fun icon(iconView: View?) = apply {
|
||||
this.iconView = iconView
|
||||
}
|
||||
|
||||
/**
|
||||
* 3D模型对应的资源
|
||||
*/
|
||||
fun icon3DRes(@RawRes icon3DRes: Int) = apply {
|
||||
this.icon3DRes = icon3DRes
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的颜色
|
||||
*/
|
||||
fun anchorColor(anchorColor: String?) = apply {
|
||||
this.anchorColor = anchorColor
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
fun moveToCenter(flag: Boolean) = apply {
|
||||
this.moveToCenter = flag
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建Options对象
|
||||
*/
|
||||
fun build(): Options {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw AssertionError("id must not be null.")
|
||||
}
|
||||
return Options(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Point
|
||||
|
||||
if (id != other.id) return false
|
||||
if (owner != other.owner) return false
|
||||
if (level != other.level) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + owner.hashCode()
|
||||
result = 31 * result + level.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.map.overlay.proxy
|
||||
|
||||
|
||||
interface IMapOverlay {
|
||||
|
||||
/**
|
||||
* 删除当前marker并销毁Marker的图片等资源
|
||||
*/
|
||||
fun destroy()
|
||||
|
||||
/**
|
||||
* 删除当前marker。
|
||||
*/
|
||||
fun remove()
|
||||
|
||||
/**
|
||||
* 设置 Marker 覆盖物的可见属性。
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
fun setVisible(visible: Boolean)
|
||||
|
||||
/**
|
||||
* 是否已销毁
|
||||
*/
|
||||
fun isDestroyed(): Boolean
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
fun isVisible(): Boolean
|
||||
|
||||
|
||||
/**
|
||||
* 设置当前marker在最上面。
|
||||
*/
|
||||
fun setToTop()
|
||||
|
||||
/**
|
||||
* 取消当前marker在最上面
|
||||
*/
|
||||
fun setUnTop()
|
||||
|
||||
|
||||
fun onRemove(action: (id: String) -> Unit)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.map.overlay.proxy.line
|
||||
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.proxy.*
|
||||
|
||||
interface IMapPolylineOverlay: IMapOverlay {
|
||||
|
||||
fun setOptions(options: Polyline.Options)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.overlay.proxy.point
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.overlay.proxy.*
|
||||
|
||||
interface IMapPointOverlay: IMapOverlay {
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的属性选项类 通过markerOption 给marker设置属性
|
||||
*
|
||||
* @param opt
|
||||
*/
|
||||
fun setOptions(opt: Options)
|
||||
|
||||
|
||||
fun addDynamicAnchorPosition(point: MogoLatLng, angle: Float, duration: Long)
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import static com.mogo.map.marker.MarkerType.MAP_STATIC;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MarkerWrapperClickHelper;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* marker 点击事件处理
|
||||
*/
|
||||
public class AMapMarkerClickHandler {
|
||||
|
||||
private static volatile AMapMarkerClickHandler sInstance;
|
||||
|
||||
private AMapMarkerClickHandler() {
|
||||
}
|
||||
|
||||
public static AMapMarkerClickHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (AMapMarkerClickHandler.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new AMapMarkerClickHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public boolean handleMarkerClicked(Marker marker) {
|
||||
if (marker == null) {
|
||||
return false;
|
||||
}
|
||||
//地图道路上静态数,暂时只过滤traffic类型下发点击事件
|
||||
if (MarkerWrapperClickHelper.getInstance().isStaticMarker(marker.getId())){
|
||||
IMogoMarker iMogoMarker = new AMapMarkerWrapper(marker,new MogoMarkerOptions());
|
||||
iMogoMarker.setOwner(MAP_STATIC); //TODO 后续可能由于类型比较多,需要owner匹配机制,以及控制owner细粒度
|
||||
CallerLogger.INSTANCE.d("AMapMarkerWrapper", "traffic marker 点击回调");
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().onStaticMarkerClicked(iMogoMarker);
|
||||
}
|
||||
|
||||
Map<String, IMogoMarker> mogoMarkerMap = MarkerWrapperClickHelper.getInstance().getMogoMarkerMap();
|
||||
if (mogoMarkerMap.containsKey(marker.getId())) {
|
||||
IMogoMarker mogoMarker = mogoMarkerMap.get(marker.getId());
|
||||
final IMogoMarkerClickListener listener = mogoMarker.getOnMarkerClickListener();
|
||||
CallerLogger.INSTANCE.d("AMapMarkerWrapper", "marker 点击回调:%s -> %s", mogoMarker, marker);
|
||||
if (listener != null) {
|
||||
boolean result = listener.onMarkerClicked(mogoMarker);
|
||||
if (result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().onMarkerClicked(mogoMarker);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.hdcache.IHdCacheListener;
|
||||
import com.mogo.map.identify.MogoIdentifyManager;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.location.GDLocationClient;
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
@@ -112,8 +113,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private static final String TAG = "AMapViewWrapper";
|
||||
private final MapAutoView mMapView;
|
||||
private final IMogoMap mIMap;
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
|
||||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||
.carCursorRes(R.drawable.map_api_ic_current_location2)
|
||||
.naviCursorRes(R.drawable.ic_amap_navi_cursor)
|
||||
@@ -187,7 +186,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
private void initListeners() {
|
||||
mMapView.setOnMarkClickListener(this);
|
||||
mMarkerClickHandler = AMapMarkerClickHandler.getInstance();
|
||||
mMapView.setOnMapLoadedListener(this);
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnMapClickListener(this);
|
||||
@@ -768,7 +766,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onMarkClick(@NotNull Marker markerInfo) {
|
||||
mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||||
// mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -958,12 +956,12 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (isDayMode()) {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoMarkerManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DIconId());
|
||||
} else {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoMarkerManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DNightIconId());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.center.CenterLine;
|
||||
import com.mogo.map.marker.AMapInfoWindowAdapter;
|
||||
import com.mogo.map.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.map.overlay.AMapPolylineWrapper;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
|
||||
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
|
||||
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper;
|
||||
import com.mogo.map.road.RoadNameInfo;
|
||||
import com.mogo.map.uicontroller.AMapUIController;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions;
|
||||
@@ -28,7 +20,6 @@ import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerHelper;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MultiPointOverlayOptions;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
@@ -55,9 +46,9 @@ public class AMapWrapper implements IMogoMap {
|
||||
private static final String TAG = "AMapWrapper";
|
||||
|
||||
private static MapAutoViewHelper sAMap;
|
||||
private IMogoMapUIController mMapUIController;
|
||||
private final IMogoMapUIController mMapUIController;
|
||||
private MapAutoViewHelper mAMap;
|
||||
private MapAutoView mMapView;
|
||||
private final MapAutoView mMapView;
|
||||
private IMogoUiSettings mUiSettings;
|
||||
|
||||
public AMapWrapper(MapAutoViewHelper map, MapAutoView mapView, IMogoMapUIController controller) {
|
||||
@@ -67,7 +58,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
this.mMapView = mapView;
|
||||
mMapUIController = controller;
|
||||
// 设置实现自定义 info window
|
||||
MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter());
|
||||
// MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter());
|
||||
AMapUIController.getInstance().initClient(mMapUIController);
|
||||
}
|
||||
|
||||
@@ -92,7 +83,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker addMarker(String tag, MogoMarkerOptions options) {
|
||||
public IMapPointOverlay addPoint(com.mogo.map.overlay.point.Point.Options options) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
@@ -101,18 +92,28 @@ public class AMapWrapper implements IMogoMap {
|
||||
CallerLogger.INSTANCE.e(TAG, "marker参数为空");
|
||||
return null;
|
||||
}
|
||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper(mAMap.addMarker(markerOptions), options);
|
||||
if (options.isAutoManager()) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().add(tag, mogoMarker);
|
||||
Marker delegate = mAMap.addMarker(markerOptions);
|
||||
if (delegate == null) {
|
||||
return null;
|
||||
}
|
||||
return mogoMarker;
|
||||
return new AMapPointWrapper(options.getId(), delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllMarkers() {
|
||||
if (sAMap != null) {
|
||||
sAMap.clearAllMarkers();
|
||||
public IMapPolylineOverlay addLine(com.mogo.map.overlay.line.Polyline.Options options) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options);
|
||||
if (polylineOptions == null) {
|
||||
CallerLogger.INSTANCE.e(TAG, "polyline参数为空");
|
||||
return null;
|
||||
}
|
||||
Polyline delegate = polylineOptions.lineWidth > 0 ? mAMap.drawThickLine(polylineOptions) : mAMap.drawLine(polylineOptions);
|
||||
if (delegate == null) {
|
||||
return null;
|
||||
}
|
||||
return new com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper(options.getId(), delegate);
|
||||
}
|
||||
|
||||
BatchMarkerOptions batchMarkerOptions = new BatchMarkerOptions();
|
||||
@@ -197,53 +198,6 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (options == null || options.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<Marker> markers = new ArrayList<>();
|
||||
ArrayList<MarkerOptions> markerOptions = new ArrayList<>();
|
||||
ArrayList<IMogoMarker> mogoMarkers = new ArrayList<>();
|
||||
for (MogoMarkerOptions option : options) {
|
||||
if (option == null) {
|
||||
continue;
|
||||
}
|
||||
MarkerOptions mo = ObjectUtils.fromMogo(option);
|
||||
if (mo == null) {
|
||||
continue;
|
||||
}
|
||||
markerOptions.add(mo);
|
||||
}
|
||||
if (markerOptions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
MultiPointOverlayOptions multiPointOverlayOptions = new MultiPointOverlayOptions();
|
||||
multiPointOverlayOptions.setData(markerOptions);
|
||||
multiPointOverlayOptions.setMarkerIcon(R.drawable.marker_blue);
|
||||
List<MarkerOptions> data = mAMap.addMarkers(multiPointOverlayOptions).getOptions().getData();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
markers.add(new Marker(data.get(i)));
|
||||
}
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
Marker marker = markers.get(i);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
mogoMarkers.add(new AMapMarkerWrapper(marker, options.get(i)));
|
||||
}
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().add(tag, mogoMarkers);
|
||||
return mogoMarkers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (checkAMap()) {
|
||||
@@ -287,32 +241,13 @@ public class AMapWrapper implements IMogoMap {
|
||||
if (checkAMap()) {
|
||||
try {
|
||||
return mAMap.getZoom();
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPolyline addPolyline(MogoPolylineOptions options) {
|
||||
if (checkAMap()) {
|
||||
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options);
|
||||
CallerLogger.INSTANCE.d(TAG, "addPolyline %s", polylineOptions.toString());
|
||||
if (polylineOptions == null) {
|
||||
return null;
|
||||
}
|
||||
Polyline polyline = null;
|
||||
if (polylineOptions.getLineWidth() > 0) {
|
||||
polyline = mAMap.drawThickLine(polylineOptions);
|
||||
} else {
|
||||
polyline = mAMap.drawLine(polylineOptions);
|
||||
}
|
||||
return new AMapPolylineWrapper(polyline, options);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
mAMap = mMapView.getMapAutoViewHelper();
|
||||
sAMap = mAMap;
|
||||
@@ -365,8 +300,4 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mMapView.getContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.map
|
||||
|
||||
import com.mogo.map.overlay.*
|
||||
|
||||
object MoGoOverlayManager {
|
||||
|
||||
private val impl by lazy { MoGoOverlayManagerImpl() }
|
||||
|
||||
fun overlay(): IMoGoOverlayManager = impl
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.v2x.CallMarkersClearManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-20
|
||||
* <p>
|
||||
* marker 管理实现
|
||||
*/
|
||||
public class MogoMarkerManager implements IMogoMarkerManager {
|
||||
|
||||
private static final String TAG = "MogoMarkerManager";
|
||||
|
||||
private static volatile MogoMarkerManager sInstance;
|
||||
private Context mApplicationContext;
|
||||
|
||||
private MogoMarkerManager(Context context) {
|
||||
if (context != null) {
|
||||
mApplicationContext = context.getApplicationContext();
|
||||
}
|
||||
}
|
||||
|
||||
public static MogoMarkerManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoMarkerManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoMarkerManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker addMarker(String tag, MogoMarkerOptions options) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addMarker(tag, options);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addMarkers(tag, options, moveToCenter);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllMarker() {
|
||||
try{
|
||||
MogoMap.getInstance().getMogoMap().clearAllMarkers();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addPreVehicleModel(int type, int modelRes) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPreVehicleModel(type, modelRes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarker(String uuidString) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().removeMarker(uuidString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeMarkers(String tag) {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkersOfTag(tag);
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().remove(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarkers() {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().removeAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visibleAllMarkers() {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().visibleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inVisibleAllMarkers() {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().inVisibleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inVisibleWithoutMarkers(String... owner) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().inVisibleMarkers(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMogoMarker> getMarkers(String tag) {
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().getMarkers(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<IMogoMarker>> getAllMarkers() {
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().getAllMarkers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarkersExcept(String tag) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().deleteAllExcept(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRouteWay(Context context, MogoLatLng startPoint, MogoLatLng endPoint, List<MogoLatLng> wayPoints) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRouteWayOverlay() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoOverlayManager implements IMogoOverlayManager {
|
||||
|
||||
private MogoOverlayManager() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final MogoOverlayManager INSTANCE = new MogoOverlayManager();
|
||||
}
|
||||
|
||||
public static MogoOverlayManager getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPolyline addPolyline(MogoPolylineOptions options) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPolyline(options);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mogo.map.identify;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.identity.IMogoIdentifyManager;
|
||||
import java.util.HashMap;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-20
|
||||
* <p>
|
||||
* marker 管理实现
|
||||
*/
|
||||
public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
|
||||
private static final String TAG = "MogoIdentifyManager";
|
||||
|
||||
private static volatile MogoIdentifyManager sInstance;
|
||||
|
||||
private MogoIdentifyManager(Context context) {}
|
||||
|
||||
public static MogoIdentifyManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoIdentifyManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoIdentifyManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarker(String uuidString) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().removeMarker(uuidString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addPreVehicleModel(int type, int modelRes) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPreVehicleModel(type, modelRes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.AMapMarkerClickHandler;
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 自定义infowindow
|
||||
*/
|
||||
public final class AMapInfoWindowAdapter implements InfoWindowAdapter, OnInfoWindowClickListener {
|
||||
|
||||
@Override
|
||||
public View getInfoWindow(Marker marker ) {
|
||||
if ( marker.getMObject() instanceof IMogoMarker ) {
|
||||
IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getMObject() );
|
||||
IMogoInfoWindowAdapter delegate = mogoMarker.getInfoWindowAdapter();
|
||||
if ( delegate != null ) {
|
||||
final View infoView = delegate.getInfoWindow( mogoMarker );
|
||||
marker.setOnInfoWindowClickListener( this );
|
||||
return infoView;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfoWindowClick( @NotNull Marker marker ) {
|
||||
AMapMarkerClickHandler.getInstance().handleMarkerClicked( marker );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View getInfoContents( @Nullable Marker marker ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.MarkerAnimationListener;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Animation;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerScaleAnimation;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 自研marker
|
||||
*/
|
||||
public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
|
||||
private final String TAG = AMapMarkerWrapper.class.getName();
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
private IMogoMarkerClickListener mMogoMarkerClickListener;
|
||||
private IMogoInfoWindowAdapter mMogoInfoWindowAdapter;
|
||||
|
||||
private boolean mIsDestroy = false;
|
||||
|
||||
private MogoMarkerOptions mMogoMarkerOptions;
|
||||
private String mOwner;
|
||||
|
||||
public AMapMarkerWrapper( Marker marker, MogoMarkerOptions mogoMarkerOptions ) {
|
||||
this.mMarker = marker;
|
||||
if ( marker != null ) {
|
||||
// 设置自研 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setMObject( this );
|
||||
if ( !TextUtils.isEmpty( mogoMarkerOptions.getAnchorColor() ) ) {
|
||||
marker.setAnchorColor( mogoMarkerOptions.getAnchorColor() );
|
||||
}
|
||||
MarkerWrapperClickHelper.getInstance().setMogoMarkerMap( marker.getId(), this );
|
||||
}
|
||||
setObject( mogoMarkerOptions.getObject() );
|
||||
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||
mMogoMarkerOptions.addObserver( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable o, Object arg ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
setMarkerOptions( mMogoMarkerOptions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
synchronized (this) {
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
mMogoMarkerOptions.deleteObservers();
|
||||
mMogoMarkerOptions = null;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.remove();
|
||||
mMarker.setMObject( null );
|
||||
mMarker.setOnInfoWindowClickListener( null );
|
||||
mMarker = null;
|
||||
}
|
||||
}
|
||||
mMogoInfoWindowAdapter = null;
|
||||
mMogoMarkerClickListener = null;
|
||||
mObject = null;
|
||||
mIsDestroy = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAlpha( float alpha ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAlpha( alpha );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon( Bitmap icon ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcon( icon );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcons( ArrayList< Bitmap > icons ) {
|
||||
if ( icons == null || icons.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
|
||||
for ( Bitmap icon : icons ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
descriptors.add( BitmapDescriptorFactory.INSTANCE.fromBitmap( icon ) );
|
||||
}
|
||||
if ( descriptors.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcons( descriptors );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerOptions( MogoMarkerOptions opt ) {
|
||||
|
||||
final MarkerOptions options = ObjectUtils.fromMogo( opt );
|
||||
if ( options == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setMarkerOptions( options );
|
||||
setObject( opt.getObject() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject( Object object ) {
|
||||
mObject = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPosition( double lat, double lng ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPosition( new LonLatPoint( lng, lat ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getPosition() {
|
||||
if ( mMarker != null ) {
|
||||
final LonLatPoint latLng = mMarker.getPosition();
|
||||
return ObjectUtils.fromAMap( latLng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateAngle( float rotate ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setRotateAngle( rotate );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle( String title ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setTitle( title );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToTop() {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mMogoMarkerClickListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getOnMarkerClickListener() {
|
||||
return mMogoMarkerClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoInfoWindowAdapter getInfoWindowAdapter() {
|
||||
return mMogoInfoWindowAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return mIsDestroy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner( String mOwner ) {
|
||||
this.mOwner = mOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
if ( mOwner != null ) {
|
||||
return mOwner;
|
||||
}
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
return mMogoMarkerOptions.getOwner();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Marker getMarker() {
|
||||
return mMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoMarkerOptions getMogoMarkerOptions() {
|
||||
return mMogoMarkerOptions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startScaleAnimation(float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator, final OnMarkerAnimationListener listener ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarkerScaleAnimation animationScale = new MarkerScaleAnimation( fromX, toX );
|
||||
animationScale.setDuration( duration );
|
||||
// animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
// animationScale.setInterpolator(interpolator);
|
||||
animationScale.setAnimationListener( new MarkerAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
listener.onAnimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat( @NotNull Animation animation ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
listener.onAnimStart();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
mMarker.setMarkerScaleAnimation( animationScale );
|
||||
mMarker.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickable( boolean clickable ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setClickable( clickable );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGps( boolean isGps ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setGps( isGps );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String mLastAnchorColor = "";
|
||||
|
||||
@Override
|
||||
public void setAnchorColor( String anchorColor ) {
|
||||
if ( TextUtils.equals( mLastAnchorColor, anchorColor ) ) {
|
||||
return;
|
||||
}
|
||||
if (mMogoMarkerOptions != null) {
|
||||
mMogoMarkerOptions.anchorColor( anchorColor );
|
||||
}
|
||||
|
||||
if (mMarker != null) {
|
||||
mMarker.setAnchorColor( anchorColor );
|
||||
}
|
||||
mLastAnchorColor = anchorColor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerResName() {
|
||||
if ( mMarker != null ) {
|
||||
try {
|
||||
return mMarker.getMarkeOptions().getMarkerIconName();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MarkerWrapperClickHelper {
|
||||
|
||||
private volatile static MarkerWrapperClickHelper markerWrapperClickHelper;
|
||||
|
||||
private final Map<String, IMogoMarker> mogoMarkerMap = new HashMap<>();
|
||||
|
||||
private MarkerWrapperClickHelper(){
|
||||
|
||||
}
|
||||
|
||||
public void setMogoMarkerMap(String id,IMogoMarker iMogoMarker){
|
||||
if(isStaticMarker(id)){
|
||||
return;
|
||||
}
|
||||
this.mogoMarkerMap.put(id,iMogoMarker);
|
||||
}
|
||||
|
||||
public Map<String, IMogoMarker> getMogoMarkerMap() {
|
||||
return mogoMarkerMap;
|
||||
}
|
||||
|
||||
public static MarkerWrapperClickHelper getInstance(){
|
||||
if (markerWrapperClickHelper == null) {
|
||||
synchronized (MarkerWrapperClickHelper.class) {
|
||||
if (markerWrapperClickHelper == null) {
|
||||
markerWrapperClickHelper = new MarkerWrapperClickHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return markerWrapperClickHelper;
|
||||
}
|
||||
|
||||
public boolean isStaticMarker(String id){
|
||||
return id.contains("traffic");
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AMapPolylineWrapper implements IMogoPolyline {
|
||||
|
||||
private Polyline mPolyline;
|
||||
private MogoPolylineOptions mOptions;
|
||||
private boolean mIsDestroyed = false;
|
||||
|
||||
public AMapPolylineWrapper( Polyline mPolyline,
|
||||
MogoPolylineOptions mOptions ) {
|
||||
this.mPolyline = mPolyline;
|
||||
this.mOptions = mOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
mIsDestroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoints( List< MogoLatLng > lonLats ) {
|
||||
if ( lonLats == null || lonLats.isEmpty() ) {
|
||||
mPolyline.setPoints( new ArrayList<LonLatPoint>() );
|
||||
return;
|
||||
}
|
||||
ArrayList< LonLatPoint > points = new ArrayList<>();
|
||||
for ( MogoLatLng lonLat : lonLats ) {
|
||||
LonLatPoint latLng = ObjectUtils.fromMogo( lonLat );
|
||||
if ( latLng == null ) {
|
||||
continue;
|
||||
}
|
||||
points.add( latLng );
|
||||
}
|
||||
mPolyline.setPoints( points );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoLatLng > getPoints() {
|
||||
if ( mPolyline == null ) {
|
||||
return null;
|
||||
}
|
||||
ArrayList< MogoLatLng > lonLats = new ArrayList<>();
|
||||
List<LonLatPoint> points = mPolyline.getPoints();
|
||||
if ( points != null ) {
|
||||
for ( LonLatPoint latLng : points ) {
|
||||
MogoLatLng lonLat = ObjectUtils.fromAMap( latLng );
|
||||
if ( lonLat == null ) {
|
||||
continue;
|
||||
}
|
||||
lonLats.add( lonLat );
|
||||
}
|
||||
}
|
||||
return lonLats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGeodesic( boolean draw ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setGeodesic( draw );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGeodesic() {
|
||||
return mPolyline == null ? false : mPolyline.isGeodesic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDottedLine( boolean dottedLine ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setDottedLine( dottedLine );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDottedLine() {
|
||||
return mPolyline == null ? false : mPolyline.isDottedLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth( float width ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setWidth( width );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor( int color ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setColor( color );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZIndex( float zIndex ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setZIndex( zIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZIndex() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getZIndex();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.isVisible();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransparency( float transparency ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setTransparency( transparency );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOption( MogoPolylineOptions option ) {
|
||||
PolylineOptions target = ObjectUtils.fromMogo( option );
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
mOptions = option;
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setOption( target );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.mogo.map.overlay
|
||||
|
||||
import android.graphics.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.Point
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class MoGoOverlayManagerImpl: IMoGoOverlayManager {
|
||||
|
||||
private val points by lazy { ConcurrentHashMap<Point, IMapPointOverlay>() }
|
||||
|
||||
private val lines by lazy { ConcurrentHashMap<Polyline, IMapPolylineOverlay>() }
|
||||
|
||||
override fun showOrUpdatePoint(options: Options): Point? {
|
||||
synchronized(points) {
|
||||
val key = Point(options.id, options.owner, options.level, options)
|
||||
var point = points[key]
|
||||
try {
|
||||
if (point != null) {
|
||||
point.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val p = MogoMap.getInstance().mogoMap.addPoint(options)
|
||||
if (p != null) {
|
||||
p.onRemove { removed ->
|
||||
val keys = points.filterKeys { it.id == removed }
|
||||
if (keys.isNotEmpty()) {
|
||||
keys.forEach {
|
||||
points.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
points[key] = p
|
||||
point = p
|
||||
return key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
point?.also {
|
||||
key.delegate = point
|
||||
it.setToTop()
|
||||
if (options.moveToCenter) {
|
||||
moveToCenter(
|
||||
options.id,
|
||||
options.longitude,
|
||||
options.latitude,
|
||||
if (options.isGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().longitude,
|
||||
if (options.isGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().latitude
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun hidePoint(id: String) {
|
||||
points.filter { it.key.id == id && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hidePoint(p: Point) {
|
||||
points.filter { it.key == p && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsInOwner(owner: String) {
|
||||
points.filter { it.key.owner == owner && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsInLevel(level: Level) {
|
||||
points.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPoints() {
|
||||
points.filter { it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removePoint(id: String) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.id == id }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removePoint(p: Point) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key == p }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPointsInOwner(owner: String) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.owner == owner }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPointsInLevel(level: Level) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPoints() {
|
||||
synchronized(points){
|
||||
points.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
points.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPoints() {
|
||||
points.filter { !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPointsInOwner(owner: String) {
|
||||
points.filter { it.key.owner == owner && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPointsInLevel(level: Level) {
|
||||
points.filter { it.key.level == level && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showPoint(id: String) {
|
||||
points.filter { it.key.id == id && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showOrUpdateLine(options: Polyline.Options): Polyline? {
|
||||
synchronized(lines) {
|
||||
val key = Polyline(options.id, options.owner, options.level, options)
|
||||
var line = lines[key]
|
||||
try {
|
||||
if (line != null) {
|
||||
line.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val newLine = MogoMap.getInstance().mogoMap.addLine(options)
|
||||
if (newLine != null) {
|
||||
newLine.onRemove { removed ->
|
||||
val keys = lines.filterKeys { it.id == removed }
|
||||
if (keys.isNotEmpty()) {
|
||||
keys.forEach {
|
||||
lines.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
lines[key] = newLine
|
||||
line = newLine
|
||||
return key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
line?.also {
|
||||
it.setToTop()
|
||||
key.delegate = it
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun moveToCenter(id: String, eventLon: Double, eventLat: Double, carLon: Double, carLat: Double) {
|
||||
try {
|
||||
CallerMapUIServiceManager.getMapUIController()?.showBounds(
|
||||
id,
|
||||
MogoLatLng(carLat, carLon),
|
||||
listOf(MogoLatLng(eventLat, eventLon)),
|
||||
Rect(
|
||||
WindowUtils.dip2px(Utils.getApp(), 100f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 370f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 575f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 100f)
|
||||
), true)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideLine(id: String) {
|
||||
lines.filter { it.key.id == id && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideLine(p: Polyline) {
|
||||
lines.filter { it.key == p && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLinesInOwner(owner: String) {
|
||||
lines.filter { it.key.owner == owner && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLinesInLevel(level: Level) {
|
||||
lines.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLines() {
|
||||
lines.filter { it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeLine(id: String) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.id == id }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeLine(p: Polyline) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key == p }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLinesInOwner(owner: String) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.owner == owner }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLinesInLevel(level: Level) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.level == level }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLines() {
|
||||
synchronized(lines) {
|
||||
lines.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
lines.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLines() {
|
||||
lines.filter { !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLinesInOwner(owner: String) {
|
||||
lines.filter { !it.value.isVisible() && it.key.owner == owner }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLinesInLevel(level: Level) {
|
||||
lines.filter { !it.value.isVisible() && it.key.level == level }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showLine(id: String) {
|
||||
lines.filter { it.key.id == id && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsExceptIds(vararg ids: String) {
|
||||
points.filter { !ids.contains(it.key.id) && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsExceptOwners(vararg owners: String) {
|
||||
points.filter { !owners.contains(it.key.owner) && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.map.overlay.wrapper.line
|
||||
|
||||
import com.mogo.map.overlay.line.Polyline.Options
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.sdk.open.poyline.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
class AMapPolylineWrapper(private val id: String, private val delegate: Polyline): IMapPolylineOverlay {
|
||||
|
||||
private val isDestroyed by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val isRemoved by lazy { AtomicBoolean(false) }
|
||||
|
||||
@Volatile
|
||||
private var onRemoveAction: ((id: String) -> Unit)? = null
|
||||
|
||||
override fun destroy() {
|
||||
if (isDestroyed.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.destroy()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove() {
|
||||
if (isRemoved.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.remove()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setVisible(visible)
|
||||
}
|
||||
|
||||
override fun isDestroyed(): Boolean {
|
||||
return isDestroyed.get()
|
||||
}
|
||||
|
||||
override fun isVisible(): Boolean {
|
||||
return delegate.isVisible() ?: false
|
||||
}
|
||||
|
||||
override fun setToTop() {
|
||||
//没有对应的API
|
||||
}
|
||||
|
||||
override fun setUnTop() {
|
||||
//没有对应的API
|
||||
}
|
||||
|
||||
override fun setOptions(options: Options) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.also {
|
||||
val option = ObjectUtils.fromMogo(options)
|
||||
if (option != null) {
|
||||
it.setOption(option)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRemove(action: (id: String) -> Unit) {
|
||||
onRemoveAction = action
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.mogo.map.overlay.wrapper.point
|
||||
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.sdk.open.marker.*
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class AMapPointWrapper(private val id: String, private val delegate: Marker): IMapPointOverlay {
|
||||
|
||||
private val isDestroyed by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val isRemoved by lazy { AtomicBoolean(false) }
|
||||
|
||||
|
||||
@Volatile
|
||||
private var onRemoveAction: ((id: String) -> Unit)? = null
|
||||
|
||||
override fun destroy() {
|
||||
if (isDestroyed.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.destroy()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove() {
|
||||
if (isRemoved.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.remove()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setVisible(visible)
|
||||
}
|
||||
|
||||
override fun isDestroyed(): Boolean {
|
||||
return isDestroyed.get()
|
||||
}
|
||||
|
||||
override fun isVisible(): Boolean {
|
||||
return delegate.isVisible()
|
||||
}
|
||||
|
||||
override fun setToTop() {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setToTop()
|
||||
}
|
||||
|
||||
override fun setUnTop() {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setUnTop()
|
||||
}
|
||||
|
||||
override fun setOptions(opt: Options) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setMarkerOptions(ObjectUtils.fromMogo(opt))
|
||||
}
|
||||
|
||||
override fun addDynamicAnchorPosition(point: MogoLatLng, angle: Float, duration: Long) {
|
||||
delegate.addDynamicAnchorPostion(LonLatPoint(point.lon, point.lat, angle.toDouble()), System.currentTimeMillis(), duration.toInt())
|
||||
}
|
||||
|
||||
override fun onRemove(action: (id: String) -> Unit) {
|
||||
onRemoveAction = action
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,8 @@ import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
@@ -33,7 +32,7 @@ import mogo.yycp.api.proto.SocketDownData;
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
public static MarkerOptions fromMogo(MogoMarkerOptions opt) {
|
||||
public static MarkerOptions fromMogo(Point.Options opt) {
|
||||
|
||||
if (opt == null) {
|
||||
return null;
|
||||
@@ -59,25 +58,26 @@ public class ObjectUtils {
|
||||
.rotateAngle(opt.getRotate())
|
||||
.setFlat(opt.isFlat())
|
||||
.visible(opt.isVisible())
|
||||
.infoWindowEnable(opt.isInifoWindowEnable())
|
||||
.infoWindowEnable(opt.isInfoWindowEnable())
|
||||
.scale(opt.getScale())
|
||||
.alpha(opt.getAlpha())
|
||||
.setInfoWindowOffset(opt.getOffsetX(), opt.getOffsetY())
|
||||
.zIndex(opt.getzIndex());
|
||||
.zIndex(opt.getLevel().getZIndex());
|
||||
|
||||
try {
|
||||
if (!TextUtils.isEmpty(opt.getAnchorColor())) {
|
||||
Color.parseColor(opt.getAnchorColor());
|
||||
markerOptions.anchorColor(opt.getAnchorColor());
|
||||
String anchorColor = opt.getAnchorColor();
|
||||
if (anchorColor != null && !TextUtils.isEmpty(anchorColor)) {
|
||||
Color.parseColor(anchorColor);
|
||||
markerOptions.anchorColor(anchorColor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
markerOptions.vrEnable(opt.is3DMode());
|
||||
if (!TextUtils.isEmpty(opt.getResName())) {
|
||||
markerOptions.setMarkerIconName(opt.getResName());
|
||||
String resName = opt.getResName();
|
||||
if (resName != null && !TextUtils.isEmpty(resName)) {
|
||||
markerOptions.setMarkerIconName(resName);
|
||||
} else {
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt);
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt.getIcon(), opt.getIconView());
|
||||
if (descriptor != null) {
|
||||
markerOptions.markerIcon(descriptor);
|
||||
}
|
||||
@@ -85,11 +85,13 @@ public class ObjectUtils {
|
||||
markerOptions.marker3DIcon(opt.getIcon3DRes());
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getTitle())) {
|
||||
markerOptions.title(opt.getTitle());
|
||||
String title = opt.getTitle();
|
||||
if (title != null && !TextUtils.isEmpty(title)) {
|
||||
markerOptions.title(title);
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getSnippet())) {
|
||||
markerOptions.snippet(opt.getSnippet());
|
||||
String snippet = opt.getSnippet();
|
||||
if (snippet != null && !TextUtils.isEmpty(snippet)) {
|
||||
markerOptions.snippet(snippet);
|
||||
}
|
||||
return markerOptions;
|
||||
}
|
||||
@@ -107,7 +109,8 @@ public class ObjectUtils {
|
||||
markerOptions.setLat(trafficData.getLatitude());
|
||||
markerOptions.setLon(trafficData.getLongitude());
|
||||
markerOptions.setTime(Double.valueOf(trafficData.getSatelliteTime() * 1000).longValue());
|
||||
if(trafficData.getColor()!=null && !trafficData.getColor().isEmpty()){
|
||||
trafficData.getColor();
|
||||
if(!trafficData.getColor().isEmpty()){
|
||||
markerOptions.setColor(trafficData.getColor());
|
||||
}else{
|
||||
markerOptions.setColor("#00000000");
|
||||
@@ -138,68 +141,16 @@ public class ObjectUtils {
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
Bitmap icon = options.getIcon();
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(Bitmap icon, View view) {
|
||||
if (icon != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
|
||||
}
|
||||
View view = options.getIconView();
|
||||
if (view != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromView(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static MogoLocation fromLocation(com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation) {
|
||||
if (aLocation == null) {
|
||||
return null;
|
||||
}
|
||||
MogoLocation location = new MogoLocation();
|
||||
|
||||
//agps 高德
|
||||
//agps_rtk 高德-高精
|
||||
if (aLocation.getProvider().isEmpty()) {
|
||||
location.setLocType(0);
|
||||
}
|
||||
if ("AGPS".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1); // 定位类型为高德坐标(网路或者硬件定位)
|
||||
} else if ("AGPS_RTK".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1000); // 定位类型为WGS84进行转译的坐标
|
||||
} else {
|
||||
location.setLocType(0);
|
||||
}
|
||||
location.setSatellite(4);
|
||||
location.setGnssSpeed(aLocation.getSpeed());
|
||||
location.setLatitude(aLocation.getLat());
|
||||
location.setLongitude(aLocation.getLon());
|
||||
location.setAltitude(aLocation.getAltitude());
|
||||
location.setHeading((float) aLocation.getHeading());
|
||||
location.setCityCode(aLocation.getCityCode());
|
||||
location.setCityName(aLocation.getCity());
|
||||
location.setProvider(aLocation.getProvider());
|
||||
location.setAddress(aLocation.getAddress());
|
||||
location.setDistrict(aLocation.getDistrict());
|
||||
location.setProvince(aLocation.getProvince());
|
||||
location.setAdCode(aLocation.getAdCode());
|
||||
// location.setAccuracy( aLocation.getAccuracy() );
|
||||
// location.setTime( aLocation.getTime() );
|
||||
// location.setLocationDetail( aLocation.getLocationDetail() );
|
||||
// location.setPoiName( aLocation.getPoiName() );
|
||||
// location.setAoiName( aLocation.getAoiName() );
|
||||
// location.setErrCode( aLocation.getErrorCode() );
|
||||
// location.setErrInfo( aLocation.getErrorInfo() );
|
||||
// location.setStreetNum( aLocation.getStreetNum() );
|
||||
// location.setDescription( aLocation.getDescription() );
|
||||
// location.setBuildingId( aLocation.getBuildingId() );
|
||||
// location.setFloor( aLocation.getFloor() );
|
||||
// location.setGpsAccuracyStatus( aLocation.getGpsAccuracyStatus() );
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LonLatPoint fromMogo(MogoLatLng latLng) {
|
||||
if (latLng == null) {
|
||||
return null;
|
||||
@@ -214,12 +165,12 @@ public class ObjectUtils {
|
||||
return new MogoLatLng(point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
|
||||
public static PolylineOptions fromMogo(MogoPolylineOptions options) {
|
||||
public static PolylineOptions fromMogo(Polyline.Options options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions target = new PolylineOptions();
|
||||
target.setGps(options.gps());
|
||||
target.setGps(options.isUseGps());
|
||||
if (options.getPoints() != null) {
|
||||
List<LonLatPoint> points = new ArrayList<>();
|
||||
for (MogoLatLng point : options.getPoints()) {
|
||||
@@ -228,20 +179,24 @@ public class ObjectUtils {
|
||||
target.lonLatPoints(points);
|
||||
}
|
||||
target.setLineWidth(options.getWidth());
|
||||
target.zIndex(options.getZIndex());
|
||||
target.dottedLine(options.isDottedLine());
|
||||
target.geodesic(options.isGeodesic());
|
||||
target.dottedLineType(options.getDottedLineType());
|
||||
target.zIndex(options.getLevel().getZIndex());
|
||||
target.setColor(options.getColor());
|
||||
target.useGradient(options.isGradient());
|
||||
target.useFacade(options.useFacade);
|
||||
if (options.maxIndex >= 0f) {
|
||||
target.maxIndex = options.maxIndex;
|
||||
target.useFacade(options.getUseFacade());
|
||||
target.setVisible(options.isVisible());
|
||||
if (options.getMaxIndex() >= 0f) {
|
||||
target.maxIndex = options.getMaxIndex();
|
||||
}
|
||||
if (options.getColorValues() != null) {
|
||||
target.colorValues(options.getColorValues());
|
||||
if (options.getColors() != null) {
|
||||
target.colorValues(options.getColors());
|
||||
}
|
||||
if (options.isBrightOn()) {
|
||||
if (options.isLightOn()) {
|
||||
target.isBright = true;
|
||||
target.brightColor = options.getBrightColor();
|
||||
target.brightSpeed = options.getBrightSpeed();
|
||||
target.brightColor = options.getLightColor();
|
||||
target.brightSpeed = options.getLightSpeed();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
rootProject.name = 'MoGoEagleEye'
|
||||
include ':app'
|
||||
include ':app_ipc_monitoring'
|
||||
//include ':app_ipc_monitoring'
|
||||
//include ':app_mogo_magic_ring'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user